diff options
Diffstat (limited to 'src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php')
-rw-r--r-- | src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php b/src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php index b893ea29..fc175f67 100644 --- a/src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php +++ b/src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php | |||
@@ -9,19 +9,23 @@ 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 | { |
15 | protected $em; | 17 | protected $em; |
16 | protected $userRepository; | 18 | protected $userRepository; |
17 | protected $import; | 19 | protected $import; |
20 | protected $eventDispatcher; | ||
18 | protected $logger; | 21 | protected $logger; |
19 | 22 | ||
20 | public function __construct(EntityManager $em, UserRepository $userRepository, AbstractImport $import, LoggerInterface $logger = null) | 23 | public function __construct(EntityManager $em, UserRepository $userRepository, AbstractImport $import, EventDispatcherInterface $eventDispatcher, LoggerInterface $logger = null) |
21 | { | 24 | { |
22 | $this->em = $em; | 25 | $this->em = $em; |
23 | $this->userRepository = $userRepository; | 26 | $this->userRepository = $userRepository; |
24 | $this->import = $import; | 27 | $this->import = $import; |
28 | $this->eventDispatcher = $eventDispatcher; | ||
25 | $this->logger = $logger ?: new NullLogger(); | 29 | $this->logger = $logger ?: new NullLogger(); |
26 | } | 30 | } |
27 | 31 | ||
@@ -59,6 +63,9 @@ abstract class AbstractConsumer | |||
59 | try { | 63 | try { |
60 | $this->em->flush(); | 64 | $this->em->flush(); |
61 | 65 | ||
66 | // entry saved, dispatch event about it! | ||
67 | $this->eventDispatcher->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry)); | ||
68 | |||
62 | // clear only affected entities | 69 | // clear only affected entities |
63 | $this->em->clear(Entry::class); | 70 | $this->em->clear(Entry::class); |
64 | $this->em->clear(Tag::class); | 71 | $this->em->clear(Tag::class); |