-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[EventDispatcher] added EventDispatcher::getListenerPriority() #16198
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
Conversation
@@ -177,8 +192,6 @@ protected function doDispatch($listeners, $eventName, Event $event) | |||
*/ | |||
private function sortListeners($eventName) | |||
{ | |||
$this->sorted[$eventName] = array(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed as we override the value just afterwards.
Doing |
0ebb50f
to
309dc63
Compare
*/ | ||
public function getListenerPriority($eventName, $listener) | ||
{ | ||
if (null === $eventName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this does not make sense. It cannot be null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed, wrong copy/paste. fixed
309dc63
to
068e955
Compare
…iority() (fabpot) This PR was merged into the 2.8 branch. Discussion ---------- [EventDispatcher] added EventDispatcher::getListenerPriority() | Q | A | ------------- | --- | Bug fix? | yes | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #14563, #15825 | License | MIT | Doc PR | n/a In #14563, we added a way to get the priorities of listeners, but as noted by @Tobion in #15825, the implementation is sub-optimal because of two main reasons: the change is not part of the interface but more importantly, the added boolean changes the return value of `getListeners()`. This PR reverts most of #14563 to add a `getListenerPriority()` method. This method is quite slow, but as it should only be used for debugging purposes (on the CLI or the WDT), I think it's not really a problem. In 3.0, this method should probably be added to `EventDispatcherInterface`. ping @Tobion Commits ------- 068e955 [EventDispatcher] added EventDispatcher::getListenerPriority()
* Returns null if the event or the listener does not exist. | ||
* | ||
* @param string $eventName The name of the event | ||
* @param callable $listener The listener to remove |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
This PR was merged into the 2.8 branch. Discussion ---------- [EventDispatcher] fix docblock | Q | A | ------------- | --- | Fixed tickets | #16198 (comment) | License | MIT Commits ------- 6e515fb [EventDispatcher] fix docblock
…interface (xabbuh) This PR was merged into the 3.0-dev branch. Discussion ---------- [EventDispatcher] add method getListenerPriority() to interface | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | yes | Deprecations? | no | Tests pass? | yes | Fixed tickets | #16198 | License | MIT | Doc PR | todo Commits ------- f8019c8 add method getListenerPriority() to interface
For the time being, do not support wildcard patterns with getListenerPriority(). An exception will be thrown if getListenerPriority() is not implemented on the inner dispatcher. The method was added in symfony/symfony#16198 for Symfony 2.8. It was added to the interface in Symfony 3.0, which is relevant for our test cases.
In #14563, we added a way to get the priorities of listeners, but as noted by @Tobion in #15825, the implementation is sub-optimal because of two main reasons: the change is not part of the interface but more importantly, the added boolean changes the return value of
getListeners()
.This PR reverts most of #14563 to add a
getListenerPriority()
method. This method is quite slow, but as it should only be used for debugging purposes (on the CLI or the WDT), I think it's not really a problem.In 3.0, this method should probably be added to
EventDispatcherInterface
.ping @Tobion