Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feature #33851 [EventDispatcher] Allow to omit the event name when re…
…gistering listeners (derrabus) This PR was merged into the 4.4 branch. Discussion ---------- [EventDispatcher] Allow to omit the event name when registering listeners | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | #33453 (kind of) | License | MIT | Doc PR | TODO After #30801 and #33485, this is another attempt at taking advantage of FQCN events for simplifying the registration of event listeners by inferring the event name from the parameter type declaration of the listener. This is my last attempt, I promise. 🙈 This time, I'd like to make the `event` attribute of the `kernel.event_listener` tag optional. This would allow us to build listeners like the following one without adding any attributes to the `kernel.event_listener` tag. ```php namespace App\EventListener; final class MyRequestListener { public function __invoke(RequestEvent $event): void { // do something } } ``` This in turn allows us to register a whole namespace of such listeners without having to configure each listener individually: ```YAML services: App\EventListener\: resource: ../src/EventListener/* tags: [kernel.event_listener] ``` Commits ------- 6f32584 [EventDispatcher] Allow to omit the event name when registering listeners.
- Loading branch information
Showing
3 changed files
with
179 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters