Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
Event listener from attribute should not have a default priority#43757
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
nicolas-grekas commentedOct 26, 2021
Nice catch. Can you please add a test case so that we're reminded about that behavior? |
aschempp commentedOct 28, 2021
Reviewing this feature, I realized that the Now this
|
derrabus commentedOct 28, 2021
I don't quite get why I would configure an event listener by attribute but set the priority via method call. If I use the attribute, why don't I use the attribute for everything? |
nicolas-grekas commentedOct 28, 2021
Oh indeed, priority is managed by the EventDispatcher at runtime. |
aschempp commentedOct 28, 2021
Yeah thats a good question, and maybe why this has never been added to event listeners. As far as I understand, this was added in#33628 to support priority for services that were tagged through (interface) autoconfiguration. I guess this has never become relevant for event listeners because one could use the |
There is a difference between a service not having a priority and a priority of being
0. If there is no priority (or it isnull), the event listener/service can provide a method to return the priority. This would be disabled by a default value of0.seehttps://github.com/symfony/symfony/blob/5.4/src/Symfony/Component/DependencyInjection/Compiler/PriorityTaggedServiceTrait.php#L68-L72