-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
[RFC][HttpKernel][Security] Allowed adding attributes on controller arguments that will be passed to argument resolvers. #37829
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
carsonbot
added
Status: Needs Review
RFC
RFC = Request For Comments (proposals about features that you want to be discussed)
HttpKernel
Security
Feature
labels
Aug 13, 2020
jvasseur
force-pushed
the
controller-argument-attribute
branch
3 times, most recently
from
August 19, 2020 17:59
cd82a16
to
59e74d8
Compare
jvasseur
force-pushed
the
controller-argument-attribute
branch
from
August 25, 2020 12:13
59e74d8
to
c699230
Compare
jvasseur
force-pushed
the
controller-argument-attribute
branch
from
September 2, 2020 14:44
c699230
to
2484a69
Compare
/cc @derrabus |
fabpot
approved these changes
Sep 12, 2020
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
Outdated
Show resolved
Hide resolved
carsonbot
added
Status: Reviewed
and removed
Status: Needs Review
Status: Needs Work
labels
Sep 12, 2020
This was referenced Sep 12, 2020
…rguments that will be passed to argument resolvers.
fabpot
force-pushed
the
controller-argument-attribute
branch
from
September 12, 2020 08:22
2484a69
to
20f3169
Compare
Thank you @jvasseur. |
derrabus
reviewed
Sep 12, 2020
src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadataFactory.php
Show resolved
Hide resolved
Great addition, thanks @jvasseur! |
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Feature
HttpKernel
RFC
RFC = Request For Comments (proposals about features that you want to be discussed)
Security
Status: Reviewed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: