Skip to content

Commit

Permalink
[FrameworkBundle] allowed a service to register a kernel listener mor…
Browse files Browse the repository at this point in the history
…e than once for a given event
  • Loading branch information
fabpot committed Jun 4, 2011
1 parent df81296 commit 611a4a2
Showing 1 changed file with 6 additions and 5 deletions.
Expand Up @@ -68,7 +68,7 @@ public function addListenerService($eventName, $callback, $priority = 0)
throw new \InvalidArgumentException('Expected an array("service", "method") argument');
}

$this->listenerIds[$eventName][$callback[0].'::'.$callback[1]] = array($callback[0], $callback[1], $priority);
$this->listenerIds[$eventName][] = array($callback[0], $callback[1], $priority);
}

/**
Expand All @@ -86,14 +86,15 @@ public function dispatch($eventName, Event $event = null)
list($serviceId, $method, $priority) = $args;
$listener = $this->container->get($serviceId);

if (!isset($this->listeners[$eventName][$serviceId])) {
$key = $serviceId.$method;
if (!isset($this->listeners[$eventName][$key])) {
$this->addListener($eventName, array($listener, $method), $priority);
} elseif ($listener !== $this->listeners[$eventName][$serviceId]) {
$this->removeListener($eventName, array($this->listeners[$eventName][$serviceId], $method));
} elseif ($listener !== $this->listeners[$eventName][$key]) {
$this->removeListener($eventName, array($this->listeners[$eventName][$key], $method));
$this->addListener($eventName, array($listener, $method), $priority);
}

$this->listeners[$eventName][$serviceId] = $listener;
$this->listeners[$eventName][$key] = $listener;
}
}

Expand Down

0 comments on commit 611a4a2

Please sign in to comment.