waEvent

Event handling class

Contents...

This class is used by the framework for event handling.

Methods

public function __construct ($app_id, $name, $options = array())

Class constructor. A class instance must be used to start handlers for a specified event by calling run() method.

Parameters

Example

//'frontend_product' event in 'shop' app is declared with array('menu', 'cart', 'block_aux', 'block') as the options value
//therefore, you must pass the same value for $options parameter to waEvent class constructor
$event = new waEvent('shop', 'frontend_product', array('menu', 'cart', 'block_aux', 'block'));

public static function addCustomHandler ($handler)

Links a dynamic event handler.

Parameters

Example

$handler = array(
    'object' => new someCustomClass(),
    'method' => 'eventHandler', //or array('eventHandler1', 'eventHandler2', ...)
    'event' => 'some_event',
    'event_app_id' => 'some_app',
);
waEvent::addCustomHandler($handler);

public static function clearCache()

Clears event handlers data cache stored in wa-cache/apps/system/waEvent/cache/ directory. Cache is saved if the debug mode is disabled and WA_EVENT_CLEAR_CACHE constant is not defined—you can define it in wa-config/SystemConfig.class.php file.

Example

waEvent::clearCache();

public static function reset()

Clears event handlers runtime data. This may be useful during development and debugging is event handlers data cache is not saved, i.e. when the debug mode is disabled and WA_EVENT_CLEAR_CACHE constant is not defined—you can define it in wa-config/SystemConfig.class.php file.

Example

waEvent::reset();

public function run (&$params = null)

Triggers handlers for an event passed to the class constructor.

Parameters

Example

$event_class = new waEvent($event_app_id, $name, $options);
$result = $event_class->run($params);