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

[EventDispatcher] Addevents attribute of thekernel.event_listener tag#61222

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

Conversation

@santysisi
Copy link
Contributor

QA
Branch?7.4
Bug fix?no
New feature?yes
Deprecations?yes
IssuesFix#61218
LicenseMIT

Added

  • Support for the newevents attribute in thekernel.event_listener tag, enabling registration of a listener for multiple events at once.

Deprecated

  • Theevent attribute inkernel.event_listener is now deprecated and will be removed in Symfony 8.0.
    • Using theevent attribute will trigger a deprecation warning.
    • Defining bothevent andevents will throw anInvalidArgumentException to avoid configuration conflicts.

@carsonbotcarsonbot added this to the7.4 milestoneJul 24, 2025
@santysisisantysisiforce-pushed thefeature/kernel-event_listener-events-attribute branch 2 times, most recently from6513db5 tof801995CompareJuly 24, 2025 04:40
@santysisisantysisiforce-pushed thefeature/kernel-event_listener-events-attribute branch fromf801995 to61e8043CompareJuly 24, 2025 04:54
"php":">=8.2",
"symfony/event-dispatcher-contracts":"^2.5|^3"
"symfony/event-dispatcher-contracts":"^2.5|^3",
"symfony/deprecation-contracts":"^2.5|^3"
Copy link
ContributorAuthor

@santysisisantysisiJul 24, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I added this dependency to the component because I'm using thetrigger_deprecation() function.

OskarStark reacted with thumbs up emoji
"symfony/deprecation-contracts":"^2.5|^3",
"symfony/error-handler":"^7.3|^8.0",
"symfony/event-dispatcher":"^6.4|^7.0|^8.0",
"symfony/event-dispatcher":"^7.4|^8.0",
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I'm bumping the version to 7.4 in order to use the newevents attribute instead ofevent.
Please let me know if you'd prefer a different strategy or approach. I'm happy to adjust and avoid the version bump if needed 😄

"symfony/dependency-injection":"^6.4.11|^7.1.4|^8.0",
"symfony/deprecation-contracts":"^2.5|^3",
"symfony/event-dispatcher":"^6.4|^7.0|^8.0",
"symfony/event-dispatcher":"^7.4|^8.0",
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Same here

@GromNaN
Copy link
Member

Deprecating and renaming the "event" parameter of the tag has too much impact (as shown by the diff in tests). That will cause a lot of maintenance burden for projects that define event listeners in configuration directly.

Instead, I think the event listener tag can be repeated for each listened event.

alexandre-daubois, mtarld, derrabus, lyrixx, alamirault, and santysisi reacted with thumbs up emojisantysisi reacted with heart emoji

@nicolas-grekas
Copy link
Member

I'm not sure that's the right approach. Can't we add multiple kernel.event_listener tags instead? That should be already supported.

Fan2Shrek, GromNaN, alex-dev, and santysisi reacted with thumbs up emojisantysisi reacted with heart emoji


EventDispatcher
---------------
* Deprecate attribute`event` of the`kernel.event_listener` tag in favor of`events` attribute
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
* Deprecate attribute`event` of the`kernel.event_listener` tag in favor of`events` attribute
* Deprecate attribute`event` of the`kernel.event_listener` tag in favor of`events` attribute

santysisi reacted with heart emoji
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

There are also two spaces between "tag" and "in".

santysisi reacted with heart emoji
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This deprecation must be reverted.

santysisi reacted with heart emoji

7.4
---
* Add`events` attribute of the`kernel.event_listener` tag
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
* Add`events` attribute of the`kernel.event_listener` tag
* Add`events` attribute of the`kernel.event_listener` tag

santysisi reacted with heart emoji
@OskarStark
Copy link
Contributor

We should keep tests using also the oldevent and mark it with@group legacy to ensure, this is still working

santysisi reacted with heart emoji

Copy link
Contributor

@alex-devalex-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Looking at how much changes this implementation for a minor QoL improvement bring, it is clear we should consider a less invasive approach.

I see no reason to go with supporting multiple events in the same tag. Considering a service can already have multiple kernel.event_listener targetting the same method, keeping the nesting flat and having a single event per tag ensure compatibility with everything without any breaking change.
It even matches better with the final runtime implementation: the listener method is registered multiple time in the dispatcher.

santysisi reacted with heart emoji
@santysisi
Copy link
ContributorAuthor

Hi everyone 👋,

Thank you all for taking the time to review this PR and explain why this approach might not be ideal. I understand and agree with your points, so I’ll go ahead and close this PR.

Once again, I really appreciate you all for sharing your perspectives ❤️

fabpot added a commit that referenced this pull requestOct 5, 2025
…EventListener]` (Fan2Shrek)This PR was merged into the 7.4 branch.Discussion----------[FrameworkBundle] Add support for union types on `#[AsEventListener]`| Q             | A| ------------- | ---| Branch?       | 7.4| Bug fix?      | no| New feature?  | yes| Deprecations? | no| Issues        |Fix#61218| License       | MITThis is an alternative implementation to support union types, related to issue#61218 and PR#61222.It duplicates `kernel.event_listener` tags.I'm not sure how to add tests for this — could you advise?Commits-------5d7b14f Add support for union types on AsEventListener
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@GromNaNGromNaNGromNaN left review comments

@OskarStarkOskarStarkOskarStark left review comments

@lyrixxlyrixxAwaiting requested review from lyrixx

@chalasrchalasrAwaiting requested review from chalasrchalasr is a code owner

+2 more reviewers

@mttschmttschmttsch left review comments

@alex-devalex-devalex-dev requested changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

7.4

Development

Successfully merging this pull request may close these issues.

#[AsEventListener] does not handle union types

7 participants

@santysisi@GromNaN@nicolas-grekas@OskarStark@alex-dev@mttsch@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp