Explorar el Código

[EventDispatcher] fixed notices

Fabien Potencier hace 14 años
padre
commit
09a6e6759a

+ 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