ZenMagick 0.9.10


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

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

Constant Summary
final static str

BOOTSTRAP_DONE

Fired after the inital code load is done.

final static str

INIT_DONE

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

final static str

INIT_PLUGIN_GROUP_DONE

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

Field Summary
protected mixed

$eventLog_

protected mixed

$subscribers_

Fields inherited from org.zenmagick.core\ZMObject
properties_
Method Summary
void

__construct()

Create new instance.

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
__construct, attachMethod, get, getAttachedMethods, getProperties, getPropertyNames, set, singleton

Constant Detail

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

BOOTSTRAP_DONE

public final static str BOOTSTRAP_DONE = 'bootstrap_done'

Fired after the inital code load is done.


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

INIT_DONE

public final static str INIT_DONE = 'init_done'

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


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

INIT_PLUGIN_GROUP_DONE

public final static str INIT_PLUGIN_GROUP_DONE = 'init_plugin_group_done'

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


Field Detail

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

eventLog_

protected mixed $eventLog_

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

subscribers_

protected mixed $subscribers_

Method Detail

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

__construct

public void __construct()

Create new instance.


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

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 84

detach

public void detach(mixed subscriber)

Detach a subscriber.

Parameters:
subscriber - Reference of the subscriber instance.

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

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 145

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 94

getEventLog

public array getEventLog()

Get the event log.

Returns:
Log of all events and timings.

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

instance

public static void instance()

Get instance.


ZenMagick 0.9.10