diff --git a/src/EventManager.php b/src/EventManager.php index 88b0db9..82a8614 100644 --- a/src/EventManager.php +++ b/src/EventManager.php @@ -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; } @@ -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); @@ -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)) { @@ -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)); diff --git a/src/FilterChain.php b/src/FilterChain.php index 382fc02..5db8449 100644 --- a/src/FilterChain.php +++ b/src/FilterChain.php @@ -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; }