8000 [EventDispatcher] Fix unknown priority by ro0NL · Pull Request #29822 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[EventDispatcher] Fix unknown priority #29822

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 21, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[EventDispatcher] Fix unknown priority
  • Loading branch information
ro0NL committed Feb 20, 2019
commit 9fb619ac62c2370b8377cc317ab76e56d970c2f4
Original file line number Diff line number Diff line change
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