Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' of git://github.com/zendframework/zf2
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
14 changes: 4 additions & 10 deletions src/EventManager.php
Expand Up @@ -264,7 +264,7 @@ public function attach($event, $callback, $priority = 1)
if (empty($this->events[$event])) {
$this->events[$event] = new PriorityQueue();
}
$listener = new CallbackHandler($event, $callback, array('priority' => $priority));
$listener = new CallbackHandler($callback, array('event' => $event, 'priority' => $priority));
$this->events[$event]->insert($listener, $priority);
return $listener;
}
Expand Down Expand Up @@ -292,8 +292,8 @@ public function attachAggregate(ListenerAggregate $aggregate)
*/
public function detach(CallbackHandler $listener)
{
$event = $listener->getEvent();
if (empty($this->events[$event])) {
$event = $listener->getMetadatum('event');
if (!$event || empty($this->events[$event])) {
return false;
}
$return = $this->events[$event]->remove($listener);
Expand Down Expand Up @@ -394,7 +394,7 @@ protected function triggerListeners($event, EventDescription $e, $callback = nul
if (count($staticListeners)) {
$listeners = clone $listeners;
foreach ($staticListeners as $listener) {
$priority = $listener->getOption('priority');
$priority = $listener->getMetadatum('priority');
if (null === $priority) {
$priority = 1;
} elseif (is_array($priority)) {
Expand All @@ -411,12 +411,6 @@ protected function triggerListeners($event, EventDescription $e, $callback = nul
}

foreach ($listeners as $listener) {
// If we have an invalid listener, detach it, and move on to the next
if (!$listener->isValid()) {
$this->detach($listener);
continue;
}

// Trigger the listener's callback, and push its result onto the
// response collection
$responses->push(call_user_func($listener->getCallback(), $e));
Expand Down
2 changes: 1 addition & 1 deletion src/FilterChain.php
Expand Up @@ -90,7 +90,7 @@ public function attach($callback, $priority = 1)
if (empty($callback)) {
throw new InvalidCallbackException('No callback provided');
}
$filter = new CallbackHandler(null, $callback, array('priority' => $priority));
$filter = new CallbackHandler($callback, array('priority' => $priority));
$this->filters->insert($filter, $priority);
return $filter;
}
Expand Down

0 comments on commit 2904103

Please sign in to comment.