Skip to content

Commit

Permalink
[EventDispatcher] fixed notices
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed May 30, 2011
1 parent 147f975 commit 1ad5962
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
7 changes: 7 additions & 0 deletions EventDispatcher.php
Expand Up @@ -104,6 +104,13 @@ public function hasListeners($eventName = null)
*/
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]);
}
Expand Down
11 changes: 5 additions & 6 deletions EventDispatcherInterface.php
Expand Up @@ -38,15 +38,14 @@ function dispatch($eventName, Event $event = null);
/**
* 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
Expand Down

0 comments on commit 1ad5962

Please sign in to comment.