Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Closed

Conversation

@aschempp
Copy link
Contributor

QA
Branch?5.3
Bug fix?yes
New feature?no
Deprecations?no
Tickets~
LicenseMIT
Doc PR~

There is a difference between a service not having a priority and a priority of being0. 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

@nicolas-grekas
Copy link
Member

Nice catch. Can you please add a test case so that we're reminded about that behavior?

@aschempp
Copy link
ContributorAuthor

Reviewing this feature, I realized that theRegisterListenersPass which registers event listener does not actually implementPriorityTaggedServiceTrait!https://github.com/symfony/symfony/blob/5.4/src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php#L94

Now this

  1. obviously makes my PR obsolete
  2. begs the question whether the listener should be changed to use the trait? 😅

@derrabus
Copy link
Member

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
Copy link
Member

I realized that the RegisterListenersPass which registers event listener does not actually implement PriorityTaggedServiceTrait!

Oh indeed, priority is managed by the EventDispatcher at runtime.

@aschempp
Copy link
ContributorAuthor

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?

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 theEventSubscriber pattern in that case (which is not available for e.g. security voters).

@aschemppaschempp deleted the bugfix/attribute-priority branchOctober 28, 2021 09:49
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

5.3

Development

Successfully merging this pull request may close these issues.

4 participants

@aschempp@nicolas-grekas@derrabus@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp