tastyigniter / TastyIgniter

:fire: Powerful, yet easy to use, open-source online ordering, table reservation and management system for restaurants
https://tastyigniter.com
MIT License
3.03k stars 988 forks source link

Change all namespaced events to class-based events #915

Closed ryanmitchell closed 2 years ago

ryanmitchell commented 2 years ago

Does what it says on the tin.

@sampoyigi if we are going to hold this back to v4 then what do you think about dropping support for legacy events, it makes things much easier.

ryanmitchell commented 2 years ago

This goes hand in hand with https://github.com/tastyigniter/TastyIgniter/pull/933 .

Events would become actual events... Pipelines would be used for anything we want a response from.

ryanmitchell commented 2 years ago

This should now be complete, any events that we dont get a response from are converted to classes. The remainder I'll handle in the pipe PR.

sampoyigi commented 2 years ago

Instead of removing the namespaced events, we should deprecate them and remove in v5 to avoid breaking extensions.

Nice naming convention you used for the event class names Domain\Events\Context\EventName.

For scenarios when the namespace has more than 2 levels, such as 'Admin\Events\DashboardWidgets\Charts\ExtendDatasets,' convert them to 'Admin\Events\DashboardWidgets\ExtendChartsDatasets.'

sampoyigi commented 2 years ago

With this, I believe we should leave the fireSystemEvent and fireEvent in place for the time being until we figure out the optimal way, and only replace events dispatched with Event::fire because they are global events that rarely return anything. I've also included a sample with GetActiveTheme that we can use in situations where we expect a response (maybe not the best approach but works).

I've switched to using the dispatch method rather than the event helper, and I'm open to revert.

ryanmitchell commented 2 years ago

I prefer dispatch - had used that initially but you asked me to change :)

don’t mind what event format we take but do feel it would be better to have a consistent signature/method rather than different ones for each event.

sampoyigi commented 2 years ago

I prefer dispatch - had used that initially but you asked me to change :)

My bad, it be like that sometime lol

don’t mind what event format we take but do feel it would be better to have a consistent signature/method rather than different ones for each event.

Yes, we can always revisit in future :)