ZenMagick 0.9.6


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:
DerManoMann
Version:
$Id: ZMEvents.php 1996 2009-02-27 00:46:48Z dermanomann $

Field Summary
final mixed

ALL_DONE

final mixed

BOOTSTRAP_DONE

final mixed

CONTROLLER_PROCESS_END

final mixed

CONTROLLER_PROCESS_START

final mixed

CREATE_ACCOUNT

final mixed

CREATE_ORDER

final mixed

DISPATCH_DONE

final mixed

DISPATCH_START

final mixed

FINALISE_CONTENTS

final mixed

GENERATE_EMAIL

final mixed

INIT_DONE

final mixed

LOGIN_SUCCESS

final mixed

LOGOFF_SUCCESS

final mixed

PASSWORD_CHANGED

final mixed

THEME_RESOLVED

final mixed

VIEW_DONE

final mixed

VIEW_START

Fields inherited from org.zenmagick.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 ZenMagick event.

array

getEventLog()

Get the event log.

static void

instance()

Get instance.

void

update(mixed notifier, string eventId, array args)

Generic zen-cart observer callback that delegates to internal methods...

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

Field Detail

ALL_DONE

public final mixed ALL_DONE = 'all_done'

BOOTSTRAP_DONE

public final mixed BOOTSTRAP_DONE = 'bootstrap_done'

CONTROLLER_PROCESS_END

public final mixed CONTROLLER_PROCESS_END = 'controller_process_end'

CONTROLLER_PROCESS_START

public final mixed CONTROLLER_PROCESS_START = 'controller_process_start'

CREATE_ACCOUNT

public final mixed CREATE_ACCOUNT = 'create_account'

CREATE_ORDER

public final mixed CREATE_ORDER = 'create_order'

DISPATCH_DONE

public final mixed DISPATCH_DONE = 'dispatch_done'

DISPATCH_START

public final mixed DISPATCH_START = 'dispatch_start'

FINALISE_CONTENTS

public final mixed FINALISE_CONTENTS = 'finalise_contents'

GENERATE_EMAIL

public final mixed GENERATE_EMAIL = 'generate_email'

INIT_DONE

public final mixed INIT_DONE = 'init_done'

LOGIN_SUCCESS

public final mixed LOGIN_SUCCESS = 'login_success'

LOGOFF_SUCCESS

public final mixed LOGOFF_SUCCESS = 'logoff_success'

PASSWORD_CHANGED

public final mixed PASSWORD_CHANGED = 'password_changed'

THEME_RESOLVED

public final mixed THEME_RESOLVED = 'theme_resolved'

VIEW_DONE

public final mixed VIEW_DONE = 'view_done'

VIEW_START

public final mixed VIEW_START = 'view_start'

Constructor Detail

ZMEvents

public ZMEvents()

Create new instance. /


Method Detail

attach

public void attach(mixed subscriber)

Attach a subscriber to this event source.

Parameters:
subscriber - Reference to the subscriber instance.

detach

public void detach(mixed subscriber)

Detach a subscriber.

Parameters:
subscriber - Reference of the subscriber instance.

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 array fireEvent(mixed source, string eventId, array args)

Fire ZenMagick 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.

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 zen-cart 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.6