I often use EventDiscovery in my projects - I missed it in this package :)
Actually, native EventDiscovery could discover Actions, but it registers events based on handle method parameters instead of asListener
The feature works pretty much the same as Laravel's Event Discovery - it uses Lody instead of Finder as a difference
I used an additional EventServiceProvider instead of the main ActionServiceProvider because laravel uses only these services in the event:cache command
Since we are implementing all cases in the Action class, those without Event Class in handle method parameter are also registered
Discovering Events may looks weird, because half is done by Collection, but second using hard-coded array flip.
I tried different ways to make it done using Collection grouping but decided to leave it as it is because of performance reasons & complex/confusing operations - Maybe somebody knows a better way :)
Other changes:
Updated Orchestra TestBench, because the previous version throws an error in package:discovery command
The command above was needed to register dependent ServiceProviders (Lody in this particular case)
TODO
[ ] Readme
[ ] Refactor & Publish EventServiceProvider for per-project customization such as path-resolving
[ ] Consider doing the above instead of using the config file
I often use EventDiscovery in my projects - I missed it in this package :) Actually, native EventDiscovery could discover Actions, but it registers events based on
handle
method parameters instead ofasListener
The feature works pretty much the same as Laravel's Event Discovery - it uses Lody instead of Finder as a difference
I used an additional
EventServiceProvider
instead of the mainActionServiceProvider
because laravel uses only these services in theevent:cache
commandSince we are implementing all cases in the Action class, those without Event Class in
handle
method parameter are also registeredDiscovering Events may looks weird, because half is done by Collection, but second using hard-coded array flip. I tried different ways to make it done using Collection grouping but decided to leave it as it is because of performance reasons & complex/confusing operations - Maybe somebody knows a better way :)
Other changes:
package:discovery
commandTODO