Reputation: 162
I have a manager and inside a method. Inside this method, I want to add a listener connect to Doctrine and use this :
$dispatcher = $this->container->get("event_dispatcher");
$dispatcher->addListener(Events::onFlush, function (Event $event) {
var_dump('test');die;
});
But in this case nothing append. Do you have a solution to accomplish this ? I read a lot of time documentation about listener but I don't understand why didn't work :/ (and I don't want to use EventSubscriber class)
Thank you
Upvotes: 0
Views: 77
Reputation: 3182
Your code seems good, you have to use the doctrine event dispatcher and not the Symfony one.
$doctrineEventManager = $this->em->getEventManager();
$doctrineEventManager->addEventListener(Events::onFlush, New YourEventListenerClass()});;
Upvotes: 1