Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.x] Fix ignore generic listeners as view composer #794

Merged
merged 2 commits into from
Dec 13, 2019

Conversation

arjanwestdorp
Copy link
Contributor

This fixes #793 which would throw a ReflectionException when a non-closure listener is attached to the composing: ..., creating: ... or * event.
This happens when a listener is attached like: Event::listen('*', 'MyListener@handle')

All view composers/creators are wrapped in a closure, see: Illuminate\View\Concerns\ManagesEvents@addViewEvent. That means that we can filter out all listeners that are not a closure when fetching the view composers.

Technically it would be possible though to create a view composer like Event::listen('composing: layouts.master', 'MyListener@compose'). But since there is a dedicated View::composer method I assume that's the prefered and supported way to register view composers? If we would add support for those non-closure listeners that would also mean that all listeners for the * event will be seen as view composer.

@taylorotwell taylorotwell merged commit 2ff1820 into laravel:2.0 Dec 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ReflectionException on a wildcard event listener
2 participants