diff options
Diffstat (limited to 'src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php')
-rw-r--r-- | src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php | 8 |
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; | |||
9 | use Wallabag\CoreBundle\Entity\Tag; | 9 | use Wallabag\CoreBundle\Entity\Tag; |
10 | use Psr\Log\LoggerInterface; | 10 | use Psr\Log\LoggerInterface; |
11 | use Psr\Log\NullLogger; | 11 | use Psr\Log\NullLogger; |
12 | use Symfony\Component\EventDispatcher\EventDispatcherInterface; | ||
13 | use Wallabag\CoreBundle\Event\EntrySavedEvent; | ||
12 | 14 | ||
13 | abstract class AbstractConsumer | 15 | abstract 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); |