PHP Classes

Event: Register handlers and trigger event actions

Recommend this page to a friend!
  Info   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 926 This week: 1All time: 3,855 This week: 571Up
Version License PHP version Categories
eventphp5 0.1.0Free To Use But R...5.1PHP 5, Language
Description 

Author

This package can be used to register event handlers and trigger the execution of actions when an event occurs.

There are several classes that take care about registering objects that process events, trigger the execution of actions when an event is triggered, retrieving detailed information about the events.

Picture of Michal Szpakowski
Name: Michal Szpakowski <contact>
Classes: 1 package by
Country: Poland Poland
Age: ???
All time rank: 245859 in Poland Poland
Week rank: 420 Up13 in Poland Poland Up

Details

This class is an Event simulation that resembles some other languages' functionalities, such as .NET events. The idea is that user creates an Event put in the static array in the class, accessible only via the static methods. The Event object itself is never accessible. However, there is an EventWrapper, which wraps functionality in way shown in the example.php file. To create an Event first you need to provide i.Event_Name.Event interface which has the on.Event_Name.Call and on.Event_name.Destroy functions (see documentation of Event.php). You can also provide other interface name, but the interface has to define these methods. Events are either Private, Protected or Public. Private events can be called only by the instance of EventCaller (or one of it's descendants) provided during Event creation. Making this caller private member of class makes event callable only by that class. Protected Events are callable only via the instance of a class, which name is provided during the creation. Since there is no possibility to create internal classes, object can be created to call the event. Hovewer, informational purposes require making it this way. When getting the CallerClass classname one can easily determine which module/library is the "owner" of the Event. Public events can be raised by any object which is EventCaller or one of it's descendants. Events provide datasets. Dataset is an information set which is an argument for Listeners. Listener is an object which "listens" whether the Event was raised. On raising the event, the on.Event_Name.Call is called. The callback function with one argument - dataset. Listeners have to implement the Event's interface provided at creation. Dataset can be of a null value, nevertheless handler methods must have at least one argument. Events are disposable or non-disposable. Disposable Events are unset after raising. Non-disposable stay in the memory (private events can be destroyed by unsetting the caller instance and calling the Event::callerDestroyed() function). First event is created either by the static Event::init() method or on first event creation. It's the EventCreated Event, non-disposable, with EventInfo dataset. EventCreated is raised when new event is created, as it's name says :). More documentation in the .php files. License: this package is available for non-commercial usage, after notyfying the author (szpakowski@gmail.com), on GPL License. Using this package in commercial projects has to be agreed by the author (usually free). Author does not provide any guarantees for the class. Have fun.

  Files folder image Files  
File Role Description
Plain text file ACE_Exception.php Class Exception class
Plain text file Event.php Class Base class
Plain text file EventCaller.php Class Event Caller class
Plain text file EventInfo.php Class Event Info for the EventCreated Event
Plain text file EventWrapper.php Class Wrapper class for elegant usage
Accessible without login Plain text file example.php Example Example usage
Accessible without login Plain text file README.txt Doc. README and Licence

 Version Control Unique User Downloads Download Rankings  
 0%
Total:926
This week:1
All time:3,855
This week:571Up