Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
[RFC][HttpKernel][Security] Allowed adding attributes on controller arguments that will be passed to argument resolvers.#37829
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
cd82a16
to59e74d8
Compare59e74d8
toc699230
Comparec699230
to2484a69
Compare/cc@derrabus |
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 going to play with it a little but the code LGTM.
src/Symfony/Component/HttpKernel/Tests/Fixtures/Controller/AttributeController.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
…rguments that will be passed to argument resolvers.
2484a69
to20f3169
CompareThank you@jvasseur. |
src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadataFactory.phpShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Great addition, thanks@jvasseur! |
Uh oh!
There was an error while loading.Please reload this page.
This PR allow to configure argument resolvers using PHP8 attributes.
This is basically a fix for#29692 but using a different strategy that the one proposed in the issue:
ArgumentMetadata
and let the individual resolvers decide if they want to react to the presence of the attribute.Arg
annotation.As an example, I've added (in the second commit) a
CurrentUser
attribute that allows theUserValueResolver
to always inject the current user even if the argument is not typed with theUserInterface
(to allow typing your actual class instead for example).This would allow to do things like this: