EventRegister
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.

Functions
isEvent
function isEvent(
$raising_class,
$name
)

Check if an event exists.

Parameters
raising_class

The name of the class that this event belongs to.

name

The 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_class

The name of the class that this event belongs to.

name

The 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_class

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

name

The name of the event.

Returns

False if the event already exists, true otherwise.

addHandler
function addHandler(
$raising_class,
$name,
&$catching_class,
$handler,
$staticfalse
)

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

Parameters
raiseing_class

The name of the class that will raise the event.

name

The name of the event.

catching_class

The name of the class to which the event handler belongs.

handler

The name of the function (presumably a member function of the catching class, but not necessarily) that will handle this event.

static

Optional 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,
$datafalse
)

Raises an arbitrary event for the given class.

Parameters
param

An arbitrary object that is passed by reference to the event handlers.

raisecls

The name of the class the event belongs to.

event

The name of the event.

data

An 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,
$paramsfalse
)

Activates an event for the raising object.

Parameters
raiser

The object which is raising the event.  This is passed by reference to the event handler.

event

The name of the event.

params

An optional  array of parameters to pass to the event handler.

Returns

False if the event does not exist, true otherwise.

See Also

activateEventFull