Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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

Merged

Conversation

jvasseur
Copy link
Contributor

@jvasseurjvasseur commentedAug 13, 2020
edited
Loading

QA
Branch?master
Bug fix?no
New feature?yes
Deprecations?no
TicketsFix#29692
LicenseMIT
Doc PRNot yet, will do it it this PR is accepted.

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:

  • it uses PHP attributes instead of doctrine annotation since they can be added directly on method arguments.
  • it uses a simpler design by just adding the attribute to theArgumentMetadata and let the individual resolvers decide if they want to react to the presence of the attribute.
  • it uses an attributes classe per use-case instead of an uniqueArg annotation.

As an example, I've added (in the second commit) aCurrentUser 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:

class MyController{publicfunctionindexAction(#[CurentUser]MyUser$user)    {    }}

GuilhemN, linaori, derrabus, and TomasVotruba reacted with thumbs up emojiderrabus, xabbuh, and zmitic reacted with heart emojiderrabus reacted with rocket emoji
@carsonbotcarsonbot added Status: Needs Review RFCRFC = Request For Comments (proposals about features that you want to be discussed) HttpKernel Security Feature labelsAug 13, 2020
@jvasseurjvasseurforce-pushed thecontroller-argument-attribute branch 3 times, most recently fromcd82a16 to59e74d8CompareAugust 19, 2020 17:59
@jvasseurjvasseurforce-pushed thecontroller-argument-attribute branch from59e74d8 toc699230CompareAugust 25, 2020 12:13
@nicolas-grekasnicolas-grekas added this to thenext milestoneAug 31, 2020
@jvasseurjvasseurforce-pushed thecontroller-argument-attribute branch fromc699230 to2484a69CompareSeptember 2, 2020 14:44
@fabpot
Copy link
Member

/cc@derrabus

derrabus reacted with thumbs up emoji

Copy link
Member

@fabpotfabpot left a 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.

…rguments that will be passed to argument resolvers.
@fabpotfabpotforce-pushed thecontroller-argument-attribute branch from2484a69 to20f3169CompareSeptember 12, 2020 08:22
@fabpot
Copy link
Member

Thank you@jvasseur.

@jvasseurjvasseur deleted the controller-argument-attribute branchSeptember 12, 2020 08:30
@derrabus
Copy link
Member

Great addition, thanks@jvasseur!

@nicolas-grekasnicolas-grekas removed this from thenext milestoneOct 5, 2020
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@fabpotfabpotfabpot approved these changes

@derrabusderrabusderrabus left review comments

Assignees
No one assigned
Labels
FeatureHttpKernelRFCRFC = Request For Comments (proposals about features that you want to be discussed)SecurityStatus: Reviewed
Projects
None yet
Milestone
5.2
Development

Successfully merging this pull request may close these issues.

[RFC][HttpKernel] Configurable argument value resolvers
5 participants
@jvasseur@fabpot@derrabus@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp