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.

    1 answer 1

    Your subscriber will not appear in this list because the debug:event-dispatcher command returns listener / subscriber 's that are registered with Symfony EventDispatcher, and your subscriber registered with Doctrine EventDispatcher.

    Check out the doctrine:* command listing doctrine:* , maybe there will be an alternative to the debug:event_dispatcher command debug:event_dispatcher for doctrine only