From 57dd9147d9b4864c79967b46f9d7cb77a48aaf02 Mon Sep 17 00:00:00 2001 From: Drak Date: Thu, 12 Apr 2012 15:48:16 +0545 Subject: [PATCH] [EventDispatcher] Fixed E_NOTICES with multiple eventnames per subscriber with mixed priorities --- src/Symfony/Component/EventDispatcher/EventDispatcher.php | 2 +- .../Tests/Component/EventDispatcher/EventDispatcherTest.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/EventDispatcher/EventDispatcher.php b/src/Symfony/Component/EventDispatcher/EventDispatcher.php index c1b16002d2..0227d2734c 100644 --- a/src/Symfony/Component/EventDispatcher/EventDispatcher.php +++ b/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); } } } diff --git a/tests/Symfony/Tests/Component/EventDispatcher/EventDispatcherTest.php b/tests/Symfony/Tests/Component/EventDispatcher/EventDispatcherTest.php index 90d31334f5..62cd9e5193 100644 --- a/tests/Symfony/Tests/Component/EventDispatcher/EventDispatcherTest.php +++ b/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'), + ); } }