<?xml version="1.0"?>
<?xml-stylesheet
href="http://www.w3.org/2000/08/w3c-synd/style.css" type="text/css"
?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel rdf:about="http://pear.php.net/bugs/search.php">
    <title>PEAR Bug Search Results</title>
    <link>http://pear.php.net/bugs/search.php?cmd=display&amp;package_name%5B0%5D=Event_Dispatcher</link>
    <description>Search Results</description>
    <dc:language>en-us</dc:language>
    <dc:creator>pear-webmaster@lists.php.net</dc:creator>
    <dc:publisher>pear-webmaster@lists.php.net</dc:publisher>
    <admin:generatorAgent rdf:resource="http://pear.php.net/bugs"/>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase>
    <items>
     <rdf:Seq>
      <rdf:li rdf:resource="http://pear.php.net/bug/15271" />
      <rdf:li rdf:resource="http://pear.php.net/bug/7939" />
      <rdf:li rdf:resource="http://pear.php.net/bug/7459" />

     </rdf:Seq>
    </items>
  </channel>

  <image rdf:about="http://pear.php.net/gifs/pearsmall.gif">
    <title>PEAR Bugs</title>
    <url>http://pear.php.net/gifs/pearsmall.gif</url>
    <link>http://pear.php.net/bugs</link>
  </image>

    <item rdf:about="http://pear.php.net/bug/15271">
      <title>Event_Dispatcher: Feature/Change Request 15271 [Open] Converted for php5</title>
      <link>http://pear.php.net/bugs/15271</link>
      <content:encoded><![CDATA[<pre>Event_Dispatcher Feature/Change Request
Reported by snytkine
2008-12-07T17:34:24+00:00
PHP: 5.2.0 OS: RHEL4 Package Version: 1.0.0

Description:
------------
Hi
I converted this package to be used with PHP5, made some vars really private, changed == to === in many places, which is specially important in cases like == 0 and == true
changed __construct to private, getInstance() to singleton,
is_a() to instanceof, removed passing objects by reference,
added __toString, added 2 Exception classes extending PEAR_Exception, added some input variables check to addObserver() that throw exceptions on validation failures,
added option to pass only an object as argument to addObserver() but object must have Notify() method.
This is sort of an implementation of observer design pattern  - must have Notify(). 
also added type hinting to postNotification()

Please have a look and maybe we can release the Event_Dispatcher2 for php5</pre>]]></content:encoded>
      <description><![CDATA[<pre>Event_Dispatcher Feature/Change Request
Reported by snytkine
2008-12-07T17:34:24+00:00
PHP: 5.2.0 OS: RHEL4 Package Version: 1.0.0

Description:
------------
Hi
I converted this package to be used with PHP5, made some vars really private, changed == to === in many places, which is specially important in cases like == 0 and == true
changed __construct to private, getInstance() to singleton,
is_a() to instanceof, removed passing objects by reference,
added __toString, added 2 Exception classes extending PEAR_Exception, added some input variables check to addObserver() that throw exceptions on validation failures,
added option to pass only an object as argument to addObserver() but object must have Notify() method.
This is sort of an implementation of observer design pattern  - must have Notify(). 
also added type hinting to postNotification()

Please have a look and maybe we can release the Event_Dispatcher2 for php5</pre>]]></description>
      <dc:date>2008-12-27T05:10:17+00:00</dc:date>
      <dc:creator>cert21 &amp;#x61;&amp;#116; ptd &amp;#x64;&amp;#111;&amp;#x74; net</dc:creator>
      <dc:subject>Event_Dispatcher Feature/Change Request</dc:subject>
    </item>
    <item rdf:about="http://pear.php.net/bug/7939">
      <title>Event_Dispatcher: Feature/Change Request 7939 [Open] Inheritance of Event_Dispatcher</title>
      <link>http://pear.php.net/bugs/7939</link>
      <content:encoded><![CDATA[<pre>Event_Dispatcher Feature/Change Request
Reported by enrico
2006-06-19T11:33:55+00:00
PHP: 5.1.4 OS: FreeBSD Package Version: 1.0.0

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[&quot;_Event_Dispatcher&quot;]
  */
 $GLOBALS['_Event_Dispatcher'] = array(
-                                  'NotificationClass' =&gt; 'Event_Notification',
-                                  'EventDispatcherClass' =&gt; 'Event_Dispatcher'
+                                  'NotificationClass' =&gt; '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-&gt;_name = $name;
         $this-&gt;_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]-&gt;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) &amp;&amp; is_a($this, $GLOBALS['_Event_Dispatcher']['EventDispatcherClass'])) {
+        if (isset($this) &amp;&amp; is_a($this, 'Event_Dispatcher')) {
             $this-&gt;_notificationClass = $class;
             return true;
         }</pre>]]></content:encoded>
      <description><![CDATA[<pre>Event_Dispatcher Feature/Change Request
Reported by enrico
2006-06-19T11:33:55+00:00
PHP: 5.1.4 OS: FreeBSD Package Version: 1.0.0

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[&quot;_Event_Dispatcher&quot;]
  */
 $GLOBALS['_Event_Dispatcher'] = array(
-                                  'NotificationClass' =&gt; 'Event_Notification',
-                                  'EventDispatcherClass' =&gt; 'Event_Dispatcher'
+                                  'NotificationClass' =&gt; '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-&gt;_name = $name;
         $this-&gt;_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]-&gt;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) &amp;&amp; is_a($this, $GLOBALS['_Event_Dispatcher']['EventDispatcherClass'])) {
+        if (isset($this) &amp;&amp; is_a($this, 'Event_Dispatcher')) {
             $this-&gt;_notificationClass = $class;
             return true;
         }</pre>]]></description>
      <dc:date>2006-06-19T11:33:55+00:00</dc:date>
      <dc:creator>mail &amp;#x61;&amp;#116; enricostahn &amp;#x64;&amp;#111;&amp;#x74; com</dc:creator>
      <dc:subject>Event_Dispatcher Feature/Change Request</dc:subject>
    </item>
    <item rdf:about="http://pear.php.net/bug/7459">
      <title>Event_Dispatcher: Feature/Change Request 7459 [Open] Add support for filtering notifications by class hierarchy rather than name</title>
      <link>http://pear.php.net/bugs/7459</link>
      <content:encoded><![CDATA[<pre>Event_Dispatcher Feature/Change Request
Reported by jared@...
2006-04-22T13:10:13+00:00
PHP: Irrelevant OS: Mac OS X 10.4 Package Version: 1.0.0

Description:
------------
When using the third argument of addObserver to filter 
notifications based on class name, the problem is that only 
that single class name is used when checking the class that 
posted a notification. If a subclass of that class posts a 
notification, the notification will be filtered out, 
resulting in a 1:1 coupling of an observer and a single 
superclass rather than a coupling of an observer and a class 
hierarchy. So I changed the postNotification method slightly 
to check the class hierarchy so that if a superclass in the 
hierarchy matches the class name given via addObserver, it 
doesn't filter out the notification.

The patch:

--- Event/Dispatcher.php	2005-09-22 08:37:10.000000000 
-0700
+++ DispatcherNEW.php	2006-04-22 11:03:56.000000000 -0700
@@ -267,6 +267,8 @@
             $this-&gt;_pending[$nName][] =&amp; $notification;
         }
         $objClass = get_class($notification-
&gt;getNotificationObject());
+		$objClasses = array(strtolower($objClass));
+		while($objClass = get_parent_class($objClass)) 
{ $objClasses[] = strtolower($objClass); }
 
         // Find the registered observers
         if (isset($this-&gt;_ro[$nName])) {
@@ -276,7 +278,7 @@
                     return $notification;
                 }
                 if (empty($rObserver['class']) ||
-                	strcasecmp($rObserver['class'], 
$objClass) == 0) {
+                	array_search(strtolower($rObserver
['class']), $objClasses) !== false) {
                     call_user_func_array($rObserver
['callback'], array(&amp;$notification));
                     $notification-
&gt;increaseNotificationCount();
                 }</pre>]]></content:encoded>
      <description><![CDATA[<pre>Event_Dispatcher Feature/Change Request
Reported by jared@...
2006-04-22T13:10:13+00:00
PHP: Irrelevant OS: Mac OS X 10.4 Package Version: 1.0.0

Description:
------------
When using the third argument of addObserver to filter 
notifications based on class name, the problem is that only 
that single class name is used when checking the class that 
posted a notification. If a subclass of that class posts a 
notification, the notification will be filtered out, 
resulting in a 1:1 coupling of an observer and a single 
superclass rather than a coupling of an observer and a class 
hierarchy. So I changed the postNotification method slightly 
to check the class hierarchy so that if a superclass in the 
hierarchy matches the class name given via addObserver, it 
doesn't filter out the notification.

The patch:

--- Event/Dispatcher.php	2005-09-22 08:37:10.000000000 
-0700
+++ DispatcherNEW.php	2006-04-22 11:03:56.000000000 -0700
@@ -267,6 +267,8 @@
             $this-&gt;_pending[$nName][] =&amp; $notification;
         }
         $objClass = get_class($notification-
&gt;getNotificationObject());
+		$objClasses = array(strtolower($objClass));
+		while($objClass = get_parent_class($objClass)) 
{ $objClasses[] = strtolower($objClass); }
 
         // Find the registered observers
         if (isset($this-&gt;_ro[$nName])) {
@@ -276,7 +278,7 @@
                     return $notification;
                 }
                 if (empty($rObserver['class']) ||
-                	strcasecmp($rObserver['class'], 
$objClass) == 0) {
+                	array_search(strtolower($rObserver
['class']), $objClasses) !== false) {
                     call_user_func_array($rObserver
['callback'], array(&amp;$notification));
                     $notification-
&gt;increaseNotificationCount();
                 }</pre>]]></description>
      <dc:date>2006-04-22T13:10:13+00:00</dc:date>
      <dc:creator>jared &amp;#x61;&amp;#116; intuitivefuture &amp;#x64;&amp;#111;&amp;#x74; com</dc:creator>
      <dc:subject>Event_Dispatcher Feature/Change Request</dc:subject>
    </item>
</rdf:RDF>
