ZenMagick 0.9.1


org.zenmagick.service.ZMEvents

Class ZMEvents

ZMObject
|
+--ZMEvents

public class ZMEvents
extends ZMObject

Event service.

This service will relay *all* zen-cart events to registered listeners. Subscriber have to implement the same update(..) as for registering with zen-cart directly.

Any class can subscribe. Any method of the subscriber class that matches a method name derived from a zen-cart event will be called automatically.

.

Author:
mano
Version:
$Id: ZMEvents.php 1139 2008-05-30 00:12:02Z DerManoMann $

Constructor Summary

ZMEvents()

Create new instance.

Method Summary
void

attach(mixed observer)

Attach an observer to this event source.

void

detach(mixed observer)

Detach an observer from the notifier object

protected string

event2method(string eventId, string prefix)

Convert the event id to a method name.

void

fireEvent(mixed source, string eventId, array args)

Fire ZenMagick event.

array

getEventLog()

Get the event log.

static void

instance()

Get instance.

void

update(mixed notifier, string eventId, array args)

Generic observer callback that delegates to internal methods...

Methods inherited from org.zenmagick.ZMObject
backtrace, create, log, singleton

Constructor Detail

ZMEvents

public ZMEvents()

Create new instance. /


Method Detail

attach

public void attach(mixed observer)

Attach an observer to this event source.

Parameters:
observer - Reference to the observer class or method.

detach

public void detach(mixed observer)

Detach an observer from the notifier object

Parameters:
observer - Reference to the observer class or method.

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.

fireEvent

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

Fire ZenMagick event.

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().

getEventLog

public array getEventLog()

Get the event log.

Returns:
Log of all events and timings.

instance

public static void instance()

Get instance. /


update

public void update(mixed notifier, string eventId, array args)

Generic observer callback that delegates to internal methods...

The actual method called is generated based on the event id.

Parameters:
notifier - The event source.
eventId - The event id.
args - Optional parameter; default is null.

ZenMagick 0.9.1