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
Simplify the event registration #1125
Conversation
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.
LGTM at first sight. Can you explain why some of them still require the event: kernel.request
or event: kernel.response
tag?
You mean something like this, right? - { name: kernel.event_listener, event: kernel.request, priority: 255 }
- { name: kernel.event_listener, event: kernel.response, priority: -255 } I don't think there is a way to assign two different priorities to two different events without keeping the |
- { name: kernel.event_listener, event: kernel.request, method: onKernelRequest, priority: 36 } | ||
- { name: kernel.event_listener, event: kernel.response, method: onKernelResponse } | ||
- { name: kernel.event_listener, event: kernel.request, priority: 36 } | ||
- { name: kernel.event_listener, event: kernel.response } |
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 for example, why is event: kernel.response
still required here? There's no priority attribute.
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.
Because otherwise Symfony throws an exception: Service "contao.listener.csrf_token_cookie" must define the "event" attribute on "kernel.event_listener" tags.
🤷♂
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.
Okay, but why? 😄
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.
I don't know. But three remaining event:
keys should not prevent us from merging this PR.
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.
I'm reviewing here and I would like to understand why it doesn't work so that we can either fix it or know why we have inconsistency now. Can you check which condition of RegisterListenersPass::getEventFromTypeDeclaration()
is failing?
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.
I have found the issue. The pass is looking for an __invoke()
method and if there is none, you either have to specify the event
or method
key. If no method
key is given, it is computed from the event
key.
I guess it is more correct to specify the method names in our three cases (see 4a95e51).
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.
I guess it is more correct to specify the method names in our three cases (see 4a95e51).
I agree with that 👍
I went through all definitions with an |
a9e2e7f
to
f0509ac
Compare
f0509ac
to
cf8a71a
Compare
…ave an __invoke() method
See https://symfony.com/blog/new-in-symfony-4-4-simpler-event-listeners