ソースを参照

[EventDispatcher] Fixed E_NOTICES with multiple eventnames per subscriber with mixed priorities

Drak 13 年 前
コミット
57dd9147d9

+ 1 - 1
src/Symfony/Component/EventDispatcher/EventDispatcher.php

@@ -117,7 +117,7 @@ class EventDispatcher implements EventDispatcherInterface
             if (is_string($params)) {
                 $this->addListener($eventName, array($subscriber, $params));
             } else {
-                $this->addListener($eventName, array($subscriber, $params[0]), $params[1]);
+                $this->addListener($eventName, array($subscriber, $params[0]), isset($params[1]) ? $params[1] : 0);
             }
         }
     }

+ 4 - 1
tests/Symfony/Tests/Component/EventDispatcher/EventDispatcherTest.php

@@ -241,6 +241,9 @@ class TestEventSubscriberWithPriorities implements EventSubscriberInterface
 {
     public static function getSubscribedEvents()
     {
-        return array('pre.foo' => array('preFoo', 10));
+        return array(
+            'pre.foo' => array('preFoo', 10),
+            'post.foo' => array('postFoo'),
+            );
     }
 }