aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2016-11-02 07:10:23 +0100
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-11-02 07:10:23 +0100
commit7816eb622df2353cea0ede0a3674d5eb3a01a1a9 (patch)
treeff4b67da5c88c26e2048d0665522b3e070272e03 /src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php
parente0597476d1d5f6a4a7d6ea9b76966465f3d22fb8 (diff)
downloadwallabag-7816eb622df2353cea0ede0a3674d5eb3a01a1a9.tar.gz
wallabag-7816eb622df2353cea0ede0a3674d5eb3a01a1a9.tar.zst
wallabag-7816eb622df2353cea0ede0a3674d5eb3a01a1a9.zip
Add entry.saved event to import & rest
Diffstat (limited to 'src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php')
-rw-r--r--src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php b/src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php
index b893ea29..aa7ff914 100644
--- a/src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php
+++ b/src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php
@@ -9,6 +9,8 @@ use Wallabag\CoreBundle\Entity\Entry;
9use Wallabag\CoreBundle\Entity\Tag; 9use Wallabag\CoreBundle\Entity\Tag;
10use Psr\Log\LoggerInterface; 10use Psr\Log\LoggerInterface;
11use Psr\Log\NullLogger; 11use Psr\Log\NullLogger;
12use Symfony\Component\EventDispatcher\EventDispatcherInterface;
13use Wallabag\CoreBundle\Event\EntrySavedEvent;
12 14
13abstract class AbstractConsumer 15abstract class AbstractConsumer
14{ 16{
@@ -17,11 +19,12 @@ abstract class AbstractConsumer
17 protected $import; 19 protected $import;
18 protected $logger; 20 protected $logger;
19 21
20 public function __construct(EntityManager $em, UserRepository $userRepository, AbstractImport $import, LoggerInterface $logger = null) 22 public function __construct(EntityManager $em, UserRepository $userRepository, AbstractImport $import, EventDispatcherInterface $eventDispatcher, LoggerInterface $logger = null)
21 { 23 {
22 $this->em = $em; 24 $this->em = $em;
23 $this->userRepository = $userRepository; 25 $this->userRepository = $userRepository;
24 $this->import = $import; 26 $this->import = $import;
27 $this->eventDispatcher = $eventDispatcher;
25 $this->logger = $logger ?: new NullLogger(); 28 $this->logger = $logger ?: new NullLogger();
26 } 29 }
27 30
@@ -59,6 +62,9 @@ abstract class AbstractConsumer
59 try { 62 try {
60 $this->em->flush(); 63 $this->em->flush();
61 64
65 // entry saved, dispatch event about it!
66 $this->eventDispatcher->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
67
62 // clear only affected entities 68 // clear only affected entities
63 $this->em->clear(Entry::class); 69 $this->em->clear(Entry::class);
64 $this->em->clear(Tag::class); 70 $this->em->clear(Tag::class);