[5.8] Fix incorrect event namespace in generated listener.#28007
Merged
taylorotwell merged 1 commit intolaravel:5.8from Mar 26, 2019
devcircus:fix-event-generate-namespace-in-listener
Merged
[5.8] Fix incorrect event namespace in generated listener.#28007taylorotwell merged 1 commit intolaravel:5.8from devcircus:fix-event-generate-namespace-in-listener
taylorotwell merged 1 commit intolaravel:5.8from
devcircus:fix-event-generate-namespace-in-listener
Conversation
Contributor
Author
|
The reason for assumption # 3 above is that if you have a third party namespaced event, and you include it in your EventServiceProvider without the starting '\', it will fallback to using the "App\Events" namespace for this event, which of course is incorrect as well. So adding the "\" to the beginning of the namespace for third-party events, is the only route that made sense to me. |
driesvints
approved these changes
Mar 25, 2019
Contributor
|
@devcircus |
Contributor
Author
|
Thanks. I’ll look into some tests asap. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem Summary
See #27468
The issue arises when running
event:generatefor events in third-party namespaces (non-App and non-Illuminate).The FQCN of the event (in the "use" statement at the top of the Listener class) has a preceding '\'.
Before
After
Details
In
ListenerMakeCommand, there is a check to see if the given event namespace starts with:(1) your project namespace(App)
(2)"Illuminate"
(3)"\"
So it looks like the
event:generatecommand expects 3 situations:If those assumptions are true, then you should be able to generate listeners from events in third party namespaces by adding a starting '\' to your event in the
$listenarray of your EventServiceProvider.However, if you do that, then the '\' doesn't get dropped and the namespace at the top of the generated listener for your event, will still have the starting '\'.
Solution
Simply
trimthe full event name when replacing theDummyFullEvent.