Symfony Doctrine event subscriber not listed in debug:event-dispatcher
Asked Answered
P

2

10

Symfony v3.3.4, Doctrine ORM v2.5.6

I've created an event subscriber for a doctrine entity :

AppBundle\EventListener\LivreSubscriber:
    tags:
        - { name: doctrine.event_subscriber }

It works fine ! But for a long time I tought it didn't work because the listener is not listed in the debug:event-dispatcher command :

$ docker-compose exec phpapp bin/console debug:event-dispatcher doctrine.event_subscriber

[WARNING] The event "doctrine.event_subscriber" does not have any registered listeners.

It's the same for an event listener. And also : neither the Listener nor the Subscriber is listed in the symfony profiler (Event section) ... So it works but it's strange that the listeners are not listed in the debug tool, isn't it ?

Can you tell me if you have the same behaviour with your projects ...

Praise answered 27/7, 2017 at 14:17 Comment(0)
V
11

This subscriber is doctrine subscriber, not symfony. Doctrine uses its own event manager that is not connected with symfony event dispatcher. console debug:event-dispatcher lists only subscribers that are registered in symfony event dispatcher.

Volumeter answered 27/7, 2017 at 14:32 Comment(1)
That's what I tought, but I think it's not very consistent, the command should be debug:symfony-framework-event-dispatcher or there should be a debug:doctrine-event-dispatcher command :)Praise
K
0
php bin/console debug:container --tag=doctrine.event_subscriber

OR

php bin/console debug:container --tag=doctrine.orm.entity_listener
Khelat answered 4/4 at 8:18 Comment(1)
Thank you for this code snippet, which might provide some limited, immediate help. A proper explanation would greatly improve its long-term value by showing why this is a good solution to the problem and would make it more useful to future readers with other, similar questions. Please edit your answer to add some explanation, including the assumptions you’ve made.Kandi

© 2022 - 2024 — McMap. All rights reserved.