RickDBCN / filament-email

Log emails in your Filament project
https://filament-email-demo.marcogermani.it/
MIT License
83 stars 22 forks source link

Fix issue with event registration #38

Closed jcsoriano closed 8 months ago

jcsoriano commented 8 months ago

Resolves https://github.com/RickDBCN/filament-email/issues/37

Some notes:

  1. It seems that the EmailMessageServiceProvider extending from Laravel's EventServiceProvider messes up event registration
  2. I checked other packages that listen for the MessageSent event, and they only extend from Illuminate\Support\ServiceProvider
  3. When I tried it, things started working again. The listeners in EventServiceProvider@listen get registered again, and the listener of the package gets registered automatically via autodiscovery again
  4. There is no reason to extend from EventServiceProvider just to use Event::listen, since you could technically use Event::listen from any service provider, so extending from ServiceProvider should be alright and is probably more correct. It seems extending from Illuminate\Events\EventServiceProvider is what broke listener registration on our end
what-the-diff[bot] commented 8 months ago

PR Summary 📝

  1. Elimination of the EventServiceProvider Namespace 🚫 This part of the code, a sort of digital meeting room where many of the tools our code uses to handle events, was taken out. No need to worry, this doesn't mean our toolbox is short of any tools, it just means we're reorganizing a bit!

  2. Introduction of New Characters to the Story 🎭 We've welcomed some new players into our magical code realm. This includes:

    • MessageSent class (fresh from the Illuminate\Mail\Events namespace) - it's all about dealing with email messages after they've been sent.
    • Event class from Illuminate\Support\Facades - this one helps our code to marshall events in a better way.
    • ServiceProvider from Illuminate\Support - it's a real generalist! It makes sure that the right tools for the job are in the right place at the right time.
  3. Casting a New Lead Role 🎬 Instead of the usual EventServiceProvider, we now have ServiceProvider taking the spotlight in the class declaration. It's not a scandal or coup, just a little switcheroo that will make our process more streamlined and efficient! 😉

RickDBCN commented 8 months ago

Thanks for quick fix!