Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.1.0

Request #7939 Inheritance of Event_Dispatcher
Submitted: 2006-06-19 16:33 UTC
From: enrico Assigned:
Status: Open Package: Event_Dispatcher (version 1.0.0)
PHP Version: 5.1.4 OS: FreeBSD
Roadmaps: (Not assigned)    
Subscription  


 [2006-06-19 16:33 UTC] enrico (Enrico Stahn)
Description: ------------ I tried to inherit the Event_Dispatcher class. The problem is the singleton pattern part, that create an instance of Event_Dispatcher. Their is no way no configure this like the notification class (setNotificationClass). I wrote a patch to fix this. --- /usr/local/share/pear/Event/Dispatcher.php Mon Jun 19 18:06:29 2006 +++ /usr/local/share/pear/Event/Dispatcher.php.bak Mon Jun 19 17:45:15 2006 @@ -42,8 +42,7 @@ * @global array $GLOBALS["_Event_Dispatcher"] */ $GLOBALS['_Event_Dispatcher'] = array( - 'NotificationClass' => 'Event_Notification', - 'EventDispatcherClass' => 'Event_Dispatcher' + 'NotificationClass' => 'Event_Notification' ); /** @@ -123,9 +122,9 @@ * @access private * @param string Name of the notification dispatcher. */ - function Event_Dispatcher() + function Event_Dispatcher($name) { - Event_Dispatcher::__construct(); + Event_Dispatcher::__construct($name); } /** @@ -136,8 +135,9 @@ * @access private * @param string Name of the notification dispatcher. */ - function __construct() + function __construct($name) { + $this->_name = $name; $this->_notificationClass = $GLOBALS['_Event_Dispatcher']['NotificationClass']; } @@ -158,18 +158,12 @@ static $dispatchers = array(); if (!isset($dispatchers[$name])) { - $dispatchers[$name] = new $GLOBALS['_Event_Dispatcher']['EventDispatcherClass']; - $dispatchers[$name]->name = $name; + $dispatchers[$name] = new Event_Dispatcher($name); } return $dispatchers[$name]; } - function setEventDispatcherClass($class) - { - $GLOBALS['_Event_Dispatcher']['EventDispatcherClass'] = $class; - } - /** * Registers an observer callback * @@ -472,7 +466,7 @@ */ function setNotificationClass($class) { - if (isset($this) && is_a($this, $GLOBALS['_Event_Dispatcher']['EventDispatcherClass'])) { + if (isset($this) && is_a($this, 'Event_Dispatcher')) { $this->_notificationClass = $class; return true; }

Comments