- [November 1 2014] 3.0.0 – New major release, improvements and a new namespace feature.
- [March 16 2014] v2.0.0 – A Few bugfixes, cleaned up example files and the static class is now a facade.
- [June 26 2013]: (bugfix) There was a bug in the class(es) where it always tried to return a value from event::trigger even when there were no parameters.
- [June 24 2013]: I uploaded the wrong zip file. Fixed now.
- Use static class or instantiate multiple event objects or simply use the trait to add event handling for your other classes (I have examples for all of them below!)
- Listen & Trigger events
- Temporarily suppress and unsuppress events if needed
- Programmatically clear listeners on specific events
- Have multiple listeners on the same event, ordered by a custom priority from 0-100
- Trigger events and pass any number of parameters/arguments to the listeners (modifications are “gathered” through all the listeners) and the final parameters are returned, modified or not.
Why use an event/hook class? and how does it work?
The use of event-driven programming allows you to modularize your core code or allow parts of the system to alter the behavior of other parts.
If you have ever used a CMS like Wordpress or Drupal, you have used a CMS with a event/hook system.
In the drupal community there is a saying that goes “Never hack core!” and for a good reason because whenever you update your drupal installation from say 7.0 to 7.1, if any of the files you have changed is updated—You lose your changes!
The tutorial that was here is no longer relevant due to significant change in version 3.0. There is a tutorial-like example file in the download which should be easy enough to read and learn from. If you have problems or don’t understand, I will write a tutorial for it.