-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle] make RegisterKernelListenersPass reusable #6643
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
[FrameworkBundle] make RegisterKernelListenersPass reusable #6643
Conversation
@alexandresalome quick question: why creating another dispatcher ? |
Sometimes you need to create a new dispatcher, out of Symfony kernel: Behat could be a good example. Also in applications (like gitonomy) I tend to separate business events from kernel events. I do this for separation of concerns. |
@@ -14,17 +14,47 @@ | |||
use Symfony\Component\DependencyInjection\ContainerBuilder; | |||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | |||
|
|||
/** | |||
* Compiler pass to register tagged services for an event dispatcher. | |||
*/ | |||
class RegisterKernelListenersPass implements CompilerPassInterface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then the class name isn't appropriate anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the last message in PR. It can be moved to two locations (HttpKernel or EventDispatcher).
👍 I usually duplicate this file for my application events. |
Regarding the question "should we create a new event dispatcher in our applications", the answer is clearly yes or no. That being said, whatever this usage is correct or not, we still need this class for other cases. An example: you want to create an application with a service container. Extensions in this application register services in your container. You want to allow registration on a dispatcher with tags on extension's services. See the case? Regarding the class, I think it should be moved to Waiting for advices, |
Looks good to me. I think putting it in |
I've finished this PR at #7848 |
This PR was merged into the master branch. Discussion ---------- [FrameworkBundle] make RegisterKernelListenersPass reusable | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | yes | Deprecations? | no | Tests pass? | yes | Fixed tickets | #6643 | License | MIT | Doc PR | n/a see #6643 Commits ------- 5047227 moved the kernel listener compiler pass to HttpKernel to make it reusable (refs #6643) 45f1a16 make RegisterKernelListenersPass reusable
Bug fix: no
Feature addition: kinda
Backwards compatibility break: no
When I create a new event dispatcher for my applications, I would appreciate this code to be reusable.