소스 검색

[EventDispatcher] fixed notices

Fabien Potencier 14 년 전
부모
커밋
09a6e6759a
2개의 변경된 파일12개의 추가작업 그리고 6개의 파일을 삭제
  1. 7 0
      src/Symfony/Component/EventDispatcher/EventDispatcher.php
  2. 5 6
      src/Symfony/Component/EventDispatcher/EventDispatcherInterface.php

+ 7 - 0
src/Symfony/Component/EventDispatcher/EventDispatcher.php

@@ -104,6 +104,13 @@ class EventDispatcher implements EventDispatcherInterface
      */
     public function addListener($eventName, $listener, $priority = 0)
     {
+        if (!isset($this->listeners[$eventName][$priority])) {
+            if (!isset($this->listeners[$eventName])) {
+                $this->listeners[$eventName] = array();
+            }
+            $this->listeners[$eventName][$priority] = array();
+        }
+
         $this->listeners[$eventName][$priority][] = $listener;
         unset($this->sorted[$eventName]);
     }

+ 5 - 6
src/Symfony/Component/EventDispatcher/EventDispatcherInterface.php

@@ -38,15 +38,14 @@ interface EventDispatcherInterface
     /**
      * Adds an event listener that listens on the specified events.
      *
-     * @param string|array $eventNames The event(s) to listen on.
-     * @param object $listener The listener object.
-     * @param integer $priority The higher this value, the earlier an event
-     *                          listener will be triggered in the chain.
-     *                          Defaults to 0.
+     * @param string   $eventName The event to listen on
+     * @param callable $listener  The listener
+     * @param integer  $priority  The higher this value, the earlier an event
+     *                            listener will be triggered in the chain (defaults to 0)
      *
      * @api
      */
-    function addListener($eventNames, $listener, $priority = 0);
+    function addListener($eventName, $listener, $priority = 0);
 
     /**
      * Adds an event subscriber. The subscriber is asked for all the events he is