Skip to content

EventDispatcher Autowiring #21001

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
miqrogroove opened this issue May 25, 2025 · 0 comments
Open

EventDispatcher Autowiring #21001

miqrogroove opened this issue May 25, 2025 · 0 comments

Comments

@miqrogroove
Copy link
Contributor

miqrogroove commented May 25, 2025

There's not a single mention of how to autowire the kernel's EventDispatcher service in these files:

The dispatcher is the central object of the event dispatcher system. In
general, a single dispatcher is created, which maintains a registry of
listeners. When an event is dispatched via the dispatcher, it notifies all
listeners registered with that event::

https://github.com/symfony/symfony-docs/blob/7.3/event_dispatcher.rst

My attempt:

Cannot autowire service: argument "$events" of method "__construct()" references class
"Symfony\Component\EventDispatcher\EventDispatcher" but no such service exists.
Try changing the type-hint to one of its parents:
interface "Symfony\Component\EventDispatcher\EventDispatcherInterface",
interface "Psr\EventDispatcher\EventDispatcherInterface", or
interface "Symfony\Contracts\EventDispatcher\EventDispatcherInterface".

Presumably the first suggestion from the exception message would work, but I have no idea what those three different interfaces are for.

This should be better documented somewhere.

@xabbuh xabbuh added EventDispatcher hasPR A Pull Request has already been submitted for this issue. labels May 29, 2025
@javiereguiluz javiereguiluz removed the hasPR A Pull Request has already been submitted for this issue. label May 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants