Source for file EventDispatcher.php
Documentation is available at EventDispatcher.php
* "THE BEER-WARE LICENSE" (Revision 42):
* "Sven Strittmatter" <ausserirdisch@sven-space.de> wrote this file.
* As long as you retain this notice you can do whatever you want with
* this stuff. If we meet some day, and you think this stuff is worth it,
* you can buy me a beer in return.
* @copyright Copyright (c) 2007 Sven Strittmatter
require_once dirname(__FILE__ ). "/Event.php";
* Enter description here...
* @todo complete description
* @copyright Copyright (c) 2007 Sven Strittmatter
* @author "Sven Strittmatter" <ausserirdisch@sven-space.de>
* @link http://www.sven-space.de/code/php/MVClasses
private static $_instance;
$this->_handlers = array();
if (null === self::$_instance) {
self::$_instance = new EventDispatcher();
public function addHandler($name, EventHandler $handler) {
if (!isset ($this->_handlers[$name])) {
$this->_handlers[$name] = array();
$this->_handlers[$name][] = $handler;
public function triggerEvent($event, $context = null, $info = null) {
if (!$event instanceof Event) {
$event = new Event($event, $context, $info);
$name = $event->getName();
if (!isset ($this->_handlers[$name])) {
foreach ($this->_handlers[$name] as $handler) {
$handler->handle($event);
if ($event->isCancelled()) {
|