-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[RFC] Add a new kernel event after resolving controller arguments #18362
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
Comments
Big 👍 as I could have used this one in the past. |
I suggest |
LGTM, can you submit a PR? |
can it wait until Friday evening, or is it too late for the 3.1 feature freeze ? If it is too late, I can try to work on it late this evening |
Sounds like a good idea to me. |
@stof is it the idea to modify the arguments after they've been resolved? I don't think this is a good idea due to performance. The parameter converters can each have their own I'm 100% for changing parameter converters to ArgumentValueResolvers, but right now the PC configuration would have to be fetched directly from the Request unless a small layer in-between fixes this, but would mean they need 1 value resolver which handles all current PC. Regarding the Security annotation (or controller/action annotations in general) The annotation reading is currently done on At that point, the Template, Security etc listeners simply have to request the controller information (specific annotation most likely) and can work with that. anyway, this is future talk of what I'm trying to work out
list($security) = $event->getConfiguration(Security::class); First I was thinking of making this annotation specific, but it would be far more flexible if it's simply configuration, so people with yaml or xml structures can also use this. I'm not 100% sure how to do this yet though. |
@iltar the idea is to be able to run some logic after the arguments are resolved (for instance the security annotation). |
Ah I see what you mean, you're referring to this line: https://github.com/sensiolabs/SensioFrameworkExtraBundle/blob/master/EventListener/SecurityListener.php#L95 |
@iltar yes |
This PR was merged into the 3.1-dev branch. Discussion ---------- Add the kernel.controller_arguments event | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #18362 | License | MIT | Doc PR | symfony/symfony-docs#6434 I'm not sure this can be integrated in 3.1 due to the feature freeze, but it would be great if it is, as it is a must-have to be able to make the ``@Security`` annotation compatible with the new argument resolver system (as we need to be able to run the security assertion after the resolving). I made the arguments mutable here for consistency with ``kernel.controller`` (and @fabpot replied LGTM in the RFC when I suggested it). Commits ------- af02e2a Add the kernel.controller_arguments event
Currently,
kernel.controller
is dispatched between the resolution of the controller and the resolution of arguments. this is great as it means that listeners can replace the controller being found.Currently, SensioFrameworkExtraBundle also uses this event to alter the Request object for ParamConverters so that the argument resolution will see these objects, and then run the Security annotation, relying on these converted objects being in the Request.
If the argument resolution refactoring (#18308) is merged, we would need to make security check run after the resolution of arguments (to be able to use objects converted by the ArgumentResolver in expressions, and then deprecate ParamConverter in favor of custom value resolver).
For that, I suggest adding a new kernel event triggered between the resolution of arguments and the call to the controller in HttpKernel (name of the event to be discussed). this event would not allow to change the controller (it could maybe allow to change arguments, but I'm not sure it is necessary).
The text was updated successfully, but these errors were encountered: