I have a symfony2 bundle that has an event, how can I get multiple other bundles to listen for that event?
Ie. how can I pass my dispatcher between bundles?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use the
event_dispatcherservice instead of defining your own.For example, if you’re using YAML configuration files and are defining a custom service that will dispatch events, declare
"@event_dispatcher"as an argument to your service.From a controller, you can use
$this->container->get('event_dispatcher');to accomplish the same thing.All the framework internals use this provided service, and all bundles that want to fire or listen to events globally should use it as well.