EventRegister

Handles registering events and calling the event handlers.  The event register is a hierarchical list with the following format: Raising class -> Event -> Catching class -> Callback type -> Function The first three elements should be self explanatory, as should the function name.  The callback type, however, represents how the function will be called.  The valid types are “instance” and “static”, the difference being that an instance of the class is not created for “static” callbacks.

Note that this presupposes that all events are raised and caught by a class, but this is not an absolute requirement.  For either type of callback function, if the catching class does not exist (i.e. the callback was directly registered using a dumby name), the event will be raised as a regular function.

Summary
EventRegisterHandles registering events and calling the event handlers.
Functions
isEventCheck if an event exists.
hasHandlersCheck if a given event has any handlers registered.
addEventCreates a new event.
addHandlerAdds a handler function to an event.
activateEventFullRaises an arbitrary event for the given class.
activateEventActivates an event for the raising object.

Functions

isEvent

function isEvent($raising_class,
$name)

Check if an event exists.

Parameters

raising_classThe name of the class that this event belongs to.
nameThe name of the event.

Returns

True if the event exists, false if it does not.

hasHandlers

function hasHandlers($raising_class,
$name)

Check if a given event has any handlers registered.

Parameters

raising_classThe name of the class that this event belongs to.
nameThe name of the event.

Returns

True if the event has one or more handlers registered, false if it does not.

addEvent

function addEvent($raising_class,
$name)

Creates a new event.

Parameters

raising_classThe name of the class that this event belongs to, i.e. the class that will raise it.
nameThe name of the event.

Returns

False if the event already exists, true otherwise.

addHandler

function addHandler($raising_class,  
$name,  
&$catching_class,  
$handler,  
$static = false)

Adds a handler function to an event.  If the event does not already exist, then it is created.

Parameters

raiseing_classThe name of the class that will raise the event.
nameThe name of the event.
catching_classThe name of the class to which the event handler belongs.
handlerThe name of the function (presumably a member function of the catching class, but not necessarily) that will handle this event.
staticOptional boolean parameter determing whether the method is static, i.e. does not need an instance of the class to work.  Defaults to false (instance method).

activateEventFull

function activateEventFull($param,  
$raisecls,  
$event,  
$data = false)

Raises an arbitrary event for the given class.

Parameters

paramAn arbitrary object that is passe by reference to the event handlers.
raiseclsThe name of the class the event belongs to.
eventThe name of the event.
dataAn optional array of data parameters for the event handler.

Returns

False if the event does not exist, true otherwise.

See Also

activateEvent

activateEvent

function activateEvent(&$raiser,  
$event,  
$params = false)

Activates an event for the raising object.

Parameters

raiserThe object which is raising the event.  This is passed by reference to the event handler.
eventThe name of the event.
paramsAn optional array of parameters to pass to the event handler.

Returns

False if the event does not exist, true otherwise.

See Also

activateEventFull

function isEvent($raising_class,
$name)
Check if an event exists.
function hasHandlers($raising_class,
$name)
Check if a given event has any handlers registered.
function addEvent($raising_class,
$name)
Creates a new event.
function addHandler($raising_class,  
$name,  
&$catching_class,  
$handler,  
$static = false)
Adds a handler function to an event.
function activateEventFull($param,  
$raisecls,  
$event,  
$data = false)
Raises an arbitrary event for the given class.
function activateEvent(&$raiser,  
$event,  
$params = false)
Activates an event for the raising object.
Close