[11.x] Allow disabling listener on Registered
event
#51187
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Should solve the issue #50783 (comment)
On Laravel 11 a new method
EventServiceProvider@configureEmailVerification()
was introduced.https://github.com/laravel/framework/blob/11.x/src/Illuminate/Foundation/Support/Providers/EventServiceProvider.php#L207-L213.
It works fine when having only a single event service provider, the event gets triggered and the listener works fine. But the problem is when the application has more than one event service provider the listener defined here gets executed multiple times - if the application is using 10 event service providers it will be executed 10 times. It is common to have multiple event providers, especially in DDD applications.
Unfortunately, that new method was implemented without considering applications with more than one default event service provider. It seems too late to change it without causing a breaking change.
Instead, this PR aims to allow developers to turn off the listener on custom event service providers.
An alternative to this would be overwriting
configureEmailVerification()
on the custom event service provider and leaving it empty, which seems not that nice to me.