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

fix auto discover events in Laravel 11 #97

Closed
wants to merge 4 commits into from

Conversation

julio-cavallari
Copy link

This PR aims to override the original shouldDiscoverEvents method in FilamentLoggerServiceProvider to return the correct value, since get_class($this) === __CLASS__⁠ always returns false when $this is an extension of __CLASS__, causing Laravel to not load events automatically

Override the original shouldDiscoverEvents method in FilamentLoggerServiceProvider to return the correct value Override the original shouldDiscoverEvents method in FilamentLoggerServiceProvider to return the correct value, since get_class($this) === __CLASS__⁠ always returns false when $this is an extension of __CLASS__
…aravel-11

fix: fix auto discover events in Laravel 11
@Z3d0X
Copy link
Owner

Z3d0X commented Apr 22, 2024

This would be a breaking change for 10.x earlier versions of 11.x.

Could you please explain more, what issue is being solved here, possibly with an example?

@julio-cavallari
Copy link
Author

In Laravel 11, there is no longer an EventServiceProvider available by default so that the user can activate or deactivate the automatic discovery of events by returning true in the shouldDiscoverEvents method
code

This is now done by calling the withEvents method directly from the ApplicationBuilder in bootstrap/app.php
code (2)

But the check done in the original Provider that your provider extends will always return false because of the way it is done in the original provider

Executing the method through your provider, the expression get_class($this) === __CLASS__ will always be false, and events will never be discovered automatically in Laravel 11
code (1)

@Z3d0X
Copy link
Owner

Z3d0X commented Apr 22, 2024

@julio-cavallari thanks for the detailed explaination.

I'd like to keep this simple.
We could get rid of FilamentLoggerEventServiceProvider so EventServiceProvider is no longer extended by this package.

Use Event:listen() in FilamentLoggerServiceProvider

julio-cavallari and others added 2 commits April 22, 2024 00:28
…ly to FilamentLoggerServiceProvider

Remove FilamentLoggerEventServiceProvider so that automatic event discovery works correctly in Laravel 11.x
@julio-cavallari
Copy link
Author

Done on 4143416 commit @Z3d0X

@Z3d0X
Copy link
Owner

Z3d0X commented Apr 22, 2024

replaced by #99

@Z3d0X Z3d0X closed this Apr 22, 2024
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.

2 participants