以前見たものとの主な違いは、フックされているフックの厳密なチェックです。 メソッドの可用性、引数の数などをチェックします...
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
<?php abstract class EventClass { /** * * * @var array */ protected $eventRecievers = array(); /** * - * * @var array */ protected $myEvents = array(); /** * * * @param string $prop * @param callback $val */ function __set($prop, $val) { if (in_array($prop, $ this ->myEvents)) $ this ->attachEvent($prop, $val); else throw new Exception( "Property {$prop} is not found or read only" ); } /** * Caller overloader * * @param string $name * @param array $args */ function __call($name, $args) { if (in_array($name, $ this ->myEvents)) $ this ->fireEvent($name, $args); else throw new Exception( "No such event or bad arguments given" ); } /** * * * @param srting $event * @param callback $callback */ protected function attachEvent($ event , $callback) { if (in_array($ event , $ this ->myEvents)) { if (is_array($callback) && is_object($callback[0]) && is_string($callback[1])) { $reflection = new ReflectionClass(get_class($callback[0])); try { $method = $reflection->getMethod($callback[1]); if ($method->getNumberOfParameters() == 1) $ this ->eventRecievers[$ event ][]=$callback; else throw new Exception(get_class($callback[0]). "::{$callback[1]} have more than 1 arguments" ); } catch (Exception $e) { throw new Exception( "Class " .get_class($callback[0]). " doesn't have method {$callback[1]}" ); } } else throw new Exception( "Wrong callback format" ); } else throw new Exception(__CLASS__. " has no event {$event}" ); } /** * "" * * @param string $event * @param EventArgument $argument */ protected function fireEvent($ event , $argument) { if (in_array($ event , $ this ->myEvents)) { if (is_array($ this ->eventRecievers[$ event ]) && count($ this ->eventRecievers[$ event ])) foreach ($ this ->eventRecievers[$ event ] as $callback) call_user_func_array($callback, array( new EventArgument($ this , $argument))); } else throw new Exception(__CLASS__. " have no event {$event}" ); } } class CanGenerateEvents extends EventClass { protected $myEvents = array( 'onSomething' , 'onSomethingElse' ); // Code goes here function makeSomething() { // Doing something useful... $ this ->onSomething( "someText" ); } } class WantSomething { function recieveHere(EventArgument $arg) { echo $arg->argument; } } $w = new WantSomething(); $g = new CanGenerateEvents(); $g->onSomething = array($w, 'recieveHere' ); ?> * This source code was highlighted with Source Code Highlighter .
ReflectionMethod :: getClosure()メソッドがPHPに表示された場合(以前はドキュメントに存在していましたが、明らかに5.3になりません)、call_user_func_arrayの使用を拒否し、クロージャーを使用して63行目を次のコードに置き換えます
$ this ->eventRecievers[$ event ][]=$method->getClosure();
* This source code was highlighted with Source Code Highlighter .
そして、fireEvent関数の行は次のとおりです...
$callback( new EventArgument($ this , $argument));
* This source code was highlighted with Source Code Highlighter .
UPD :忘れられたEventArgumentクラス
class EventArgument {
public $caller = null ;
public $argument = null ;
function __construct($caller, $argument = null )
{
$ this ->caller = $caller;
$ this ->argument = $argument;
}
}
* This source code was highlighted with Source Code Highlighter .