<?php
require_once 'EventAggregator.php';
/**
* Use this class to attach methods to events
*
*/
class TestClass {
static function test() { var_dump(__CLASS__); }
static function test2($a,$b,$c='a') {
var_dump($a,$b,$c);
echo $GLOBALS['Event']->getCurrentEvent();
}
}
// Instantiate the event aggregator:
$Event = EventAggregator::getInstance();
// Attach some callbacks to custom event 'testEvent':
$Event->on('testEvent',array('TestClass','test'));
$Event->on('testEvent',array('TestClass','test2'),2);
// Call the event:
$Event->testEvent(__FILE__,__LINE__,true);
// These commented lines do the same as the above - fires the event 'testEvent' with params __FILE__, __LINE__ and true
// $Event->trigger('testEvent',array(__FILE__,__LINE__,true));
// $Event->fire('testEvent',__FILE__,__LINE__,true);
?>
|