Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[EventDispatcher] check for method to exist#18388
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
xabbuh commentedMar 31, 2016
Actually, this could be seen as breaking the contract given by the parent class which strictly seen doesn't allow to throw an exception here. An alternative fix would be to keep records about the listener priorities in the |
| publicfunctiongetListenerPriority($eventName,$listener) | ||
| { | ||
| if (!method_exists($this->dispatcher,'getListenerPriority')) { | ||
| thrownew \LogicException(sprintf('The wrapped event dispatcher\'s class ("%s") does not implement the getListenerPriority() method.',get_class($this->dispatcher))); |
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.
another solution would be to fallback to the behavior used by the traceable dispatcher in 2.7 and older: register the listener at priority 0. It is better than breaking the dispatching entirely IMO (especially given that all core implementations have this method implemented so most people will have the right priority anyway)
fabpot commentedApr 28, 2016
xabbuh commentedMay 3, 2016
Updated here to treat 0 as the default listener priority. |
fabpot commentedMay 3, 2016
Thank you@xabbuh. |
This PR was merged into the 2.8 branch.Discussion----------[EventDispatcher] check for method to exist| Q | A| ------------- | ---| Branch? | 2.8| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#16301 (comment)| License | MIT| Doc PR |This change must be reverted after being merged into the `3.0` branch (the `getListenerPriority()` method was added to the interface in Symfony 3.0).Commits-------78ae2ad [EventDispatcher] check for method to exist
This change must be reverted after being merged into the
3.0branch (thegetListenerPriority()method was added to the interface in Symfony 3.0).