Skip to content

Commit

Permalink
[EventDispatcher] Fix unknown priority
Browse files Browse the repository at this point in the history
  • Loading branch information
ro0NL committed Feb 20, 2019
1 parent 47d26f6 commit 9fb619a
Showing 1 changed file with 6 additions and 2 deletions.
Expand Up @@ -29,6 +29,7 @@ class WrappedListener
private $dispatcher;
private $pretty;
private $stub;
private $priority;
private static $hasClassStub;

public function __construct($listener, $name, Stopwatch $stopwatch, EventDispatcherInterface $dispatcher = null)
Expand Down Expand Up @@ -96,19 +97,22 @@ public function getInfo($eventName)

return [
'event' => $eventName,
'priority' => null !== $this->dispatcher ? $this->dispatcher->getListenerPriority($eventName, $this->listener) : null,
'priority' => null !== $this->priority ? $this->priority : (null !== $this->dispatcher ? $this->dispatcher->getListenerPriority($eventName, $this->listener) : null),
'pretty' => $this->pretty,
'stub' => $this->stub,
];
}

public function __invoke(Event $event, $eventName, EventDispatcherInterface $dispatcher)
{
$dispatcher = $this->dispatcher ?: $dispatcher;

$this->called = true;
$this->priority = $dispatcher->getListenerPriority($eventName, $this->listener);

$e = $this->stopwatch->start($this->name, 'event_listener');

\call_user_func($this->listener, $event, $eventName, $this->dispatcher ?: $dispatcher);
\call_user_func($this->listener, $event, $eventName, $dispatcher);

if ($e->isStarted()) {
$e->stop();
Expand Down

0 comments on commit 9fb619a

Please sign in to comment.