ZenMagick 0.9.8


org.zenmagick.core.services.misc.ZMEvents
\core\services\misc\ZMEvents.php at line 34

Class ZMEvents

ZMObject
└─ZMEvents

public class ZMEvents
extends ZMObject

Event service.

Generic event service that resolves events by converting the event id to a callback method name.

.

Author:
DerManoMann
Version:
$Id: ZMEvents.php 2591 2009-11-11 03:48:45Z dermanomann $

Field Summary
final str

BOOTSTRAP_DONE

Fired after the inital code load is done.

final str

INIT_DONE

Fired once all code has been loaded and plugins are initialized.

final str

INIT_PLUGIN_GROUP_DONE

Fired once a group of plugins has been loaded and initialized.

protected mixed

$eventLog_

protected mixed

$subscribers_

Fields inherited from org.zenmagick.core.ZMObject
properties_
Constructor Summary

ZMEvents()

Create new instance.

Method Summary
void

attach(mixed subscriber)

Attach a subscriber to this event source.

void

detach(mixed subscriber)

Detach a subscriber.

protected string

event2method(string eventId, string prefix)

Convert the event id to a method name.

array

fireEvent(mixed source, string eventId, array args)

Fire event.

array

getEventLog()

Get the event log.

static void

instance()

Get instance.

Methods inherited from org.zenmagick.core.ZMObject
attachMethod, get, getAttachedMethods, getPropertyNames, set, singleton

Field Detail

\core\services\misc\ZMEvents.php at line 36

BOOTSTRAP_DONE

public final str BOOTSTRAP_DONE = 'bootstrap_done'

Fired after the inital code load is done.


\core\services\misc\ZMEvents.php at line 40

INIT_DONE

public final str INIT_DONE = 'init_done'

Fired once all code has been loaded and plugins are initialized.


\core\services\misc\ZMEvents.php at line 38

INIT_PLUGIN_GROUP_DONE

public final str INIT_PLUGIN_GROUP_DONE = 'init_plugin_group_done'

Fired once a group of plugins has been loaded and initialized.


\core\services\misc\ZMEvents.php at line 43

eventLog_

protected mixed $eventLog_

\core\services\misc\ZMEvents.php at line 42

subscribers_

protected mixed $subscribers_

Constructor Detail

\core\services\misc\ZMEvents.php at line 49

ZMEvents

public ZMEvents()

Create new instance.


Method Detail

\core\services\misc\ZMEvents.php at line 75

attach

public void attach(mixed subscriber)

Attach a subscriber to this event source.

Parameters:
subscriber - Reference to the subscriber instance.

\core\services\misc\ZMEvents.php at line 85

detach

public void detach(mixed subscriber)

Detach a subscriber.

Parameters:
subscriber - Reference of the subscriber instance.

\core\services\misc\ZMEvents.php at line 115

event2method

protected string event2method(string eventId, string prefix)

Convert the event id to a method name.

Callback method names must follow the following conventions:

For example, to handle the event NOTIFY_MODULE_END_CREATE_ACCOUNT, the method name would be onNotifyLoginSuccessViaCreateAccount(..).

Parameters:
eventId - The event id.
prefix - Optional prefix; default is 'on'.
Returns:
The corresponding method name.

\core\services\misc\ZMEvents.php at line 146

fireEvent

public array fireEvent(mixed source, string eventId, array args)

Fire event.

Subscriber may opt to return the passed in $args array or a modified version or null.

If null (or nothing) is returned, the orignal argument array is kept, if the return value is of type array it is used as new $args for the next subscriber call and as final return value.

ZenMagick event methods start with onZM.

A reference of the event source is added to the optional arguments map with the key source.

Parameters:
source - The event source.
eventId - The event id.
args - Optional parameter; default is array().
Returns:
The final $args.

\core\services\misc\ZMEvents.php at line 95

getEventLog

public array getEventLog()

Get the event log.

Returns:
Log of all events and timings.

\core\services\misc\ZMEvents.php at line 65

instance

public static void instance()

Get instance.


ZenMagick 0.9.8