WorldWideScripts.net Delivering the best Add-Ons in more than 37 languages.

中文(简体), English, हिन्दी/हिंदी, Español/Castellano, العربية, Русский язык, Français, 中文 (台灣), বাংলা, Bahasa Indonesia, اردو, Português, Deutsch, Bahasa Melayu (بهاس ملايو‎), 日本語 (にほんご), فارسی, Italiano, తెలుగు, Türkçe, ગુજરાતી, Język polski/polszczyzna, Tiếng Việt, ಕನ್ನಡ, Українська мова, ไทย
PHP Scripts / Miscellaneous

Event/Hook class

— Add-On to WorldWideScripts.net

Subscribe to our feed to stay up to date!

New! Follow us as you want it!


Event/Hook class - CodeCanyon Item for Sale

Ads

Ad: Bluehost hosting

Change log

  1. [November 1 2014] 3.0.0 – New major release, improvements and a new namespace feature.
  2. [March 16 2014] v2.0.0 – A Few bugfixes, cleaned up example files and the static class is now a facade.
  3. [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.
  4. [June 24 2013]: I uploaded the wrong zip file. Fixed now.

Features

  • 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!

Here the event (or hook) system solves that problem.

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.


Download
Other components in this categoryAll components of this author
CommentsFrequently asked questions and answers

Properties

Created:
24 June 13

Last Update:
1 November 14

Files Included:
PHP

Software Version:
PHP 5.3, PHP 5.4, PHP 5.5

Keywords

eCommerce, All Items, event, event class, event driven architecture, event driven programming, event system, events, hook, hook class, hook system, hooks, listener, php event, php hooks