I do on the manual http://symfony.com/doc/current/cookbook/doctrine/event_listeners_subscribers.html
class LifecycleSubscriber implements EventSubscriber { public function postPersist(LifecycleEventArgs $args) { $this->upload($args); } public function postUpdate(LifecycleEventArgs $args) { $this->upload($args); } public function upload(LifecycleEventArgs $args) { $entity = $args->getEntity(); if ($entity instanceof Upload) { $entityManager = $args->getEntityManager(); } } public function postFlush(PostFlushEventArgs $eventArgs) { if ($this->needsFlush) { $this->needsFlush = false; $eventArgs->getEntityManager()->flush(); } } public function getSubscribedEvents() { return array( 'postPersist', 'postUpdate', ); } } Service:
services: cyber.upload.lifecycle.subscriber: class: Cyber\UploadBundle\Event\LifecycleSubscriber tags: - { name: doctrine.event_listener, event: postPersist, connection: default } - { name: doctrine.event_listener, event: postUpdate, connection: default } - { name: doctrine.event_listener, event: prePersist, connection: default } In debug: event-dispatcher listener no
Maybe I'm not trying to use it correctly and there shouldn't be anything there.