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

Added docs about ArgumentValueResolvers#6438

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

Closed

Conversation

@linaori
Copy link
Contributor

QA
Doc fix?no
New docs?yes
Applies to3.1
Fixed tickets~

Adds the documentation for the newArgumentValueResolver feature fromsymfony/symfony#18308.

action in the forementioned functionality.

- The :class:``Symfony\\Component\\HttpKernel\\ControllerMetadata\\ArgumentMetadata`` represents
information retrieved from the method signature for the current argument it's trying to resolve.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Lists shouldn't be indented with one space in reSt, it'll end up as a blockquote. Also, please use* to be consistent with the other lists in the documentation.

@linaorilinaoriforce-pushed thefeature/argument-value-resolvers branch froma1d55d2 toa310bbcCompareApril 6, 2016 15:10
The ``ArgumentResolver`` and value resolvers are added in Symfony 3.1.

In the book, you've learned that you can add the :class:`Symfony\\Component\\HttpFoundation\\Request`
as action argument and it will be injected into the method. This is done via the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Maybe "In the book, you've learned that you can get theRequest object by adding aRequest argument to your controller."?

@wouterj
Copy link
Member

Thank you for writing the docs,@iltar! It's looking great. I'm afraid I've decorated your PR a bit with some comments, but they are mostly minor style comments.


Prior to Symfony 3.1, this logic was resolved within the ``ControllerResolver``. The old
functionality is moved to the ``LegacyArgumentResolver``, which contains the previously
used resolving logic.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

If#18495 is merged, the legacy class won't exist anymore.

@linaori
Copy link
ContributorAuthor

@fabpot in the example I'm writing theUserValueResolver which I've based on the PR in the SensioFrameworkExtraBundle. While we're at the subject, should I add this code to a PR for 3.1, wait for 3.2 or is this something specific enough that people should implement them self?

@fabpot
Copy link
Member

I think it makes sense to add this feature directly in Symfony... that's one reason we made things more flexible. Submit this to master, that could be merged into 3.1 or 3.2.

@linaorilinaoriforce-pushed thefeature/argument-value-resolvers branch fromfdce9c6 to55a87b5CompareApril 29, 2016 13:51
@linaori
Copy link
ContributorAuthor

I've rebased against the current master and added the fixes in55a87b5

is resolved, you must `yield`_ the value to the ``ArgumentResolver``.

Both methods get the ``Request`` object, which is the current request, and an
:class:`Symfony\\Component\\HttpKernel\\ControllerMetadata\\ArgumentMetadata`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I would add "instance" in this sentence: "Both methods get [...] and anArgumentMetadata instance"

@linaori
Copy link
ContributorAuthor

Any last checks? I'd say this is ready to be merged 😄

@xabbuhxabbuh added this to the3.1 milestoneMay 14, 2016
The ``ArgumentResolver`` and value resolvers were introduced in Symfony 3.1.

In the book, you've learned that you can get the :class:`Symfony\\Component\\HttpFoundation\\Request`
object via an argument in your controller. This argument has to be typehinted
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

type-hinted

@xabbuh
Copy link
Member

This looks ready to me. 👍

wouterj added a commit that referenced this pull requestJun 11, 2016
This PR was submitted for the master branch but it was merged into the 3.1 branch instead (closes#6438).Discussion----------Added docs about ArgumentValueResolvers| Q             | A| ------------- | ---| Doc fix?      | no| New docs?     | yes| Applies to    | 3.1| Fixed tickets | ~Adds the documentation for the new `ArgumentValueResolver` feature fromsymfony/symfony#18308.Commits-------f22dc96 Added docs about ArgumentValueResolvers
@wouterj
Copy link
Member

Thank you@iltar! I've merged your PR in the 3.1 branch.

I've proofread the article and fixed some class names, typos. I've also removed the section about optional value resolvers and replaced it with a tip directive. I don't think it's needed to use so much words to explain it.

If you have some time, please review the changes in66ce882 (please note that I also line wrapped some paragraphs, the diff looks way bigger than the actual changes).

@linaori
Copy link
ContributorAuthor

@wouterj I've found 2 small issues but that's about it, looks good to me!

xabbuh added a commit that referenced this pull requestJun 20, 2016
This PR was merged into the 3.1 branch.Discussion----------[#6438] some tweaks to the argument value resolverCommits-------2cdd6dc [#6438] some tweaks to the argument value resolver
fabpot added a commit to symfony/symfony that referenced this pull requestJul 1, 2016
This PR was merged into the 3.2-dev branch.Discussion----------Added a SecurityUserValueResolver for controllers| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | yes| Tests pass?   | yes| Fixed tickets | ~| License       | MIT| Doc PR        | ~This PR uses the new `ArgumentResolver` to inject a security user when the signature implies so. This is based on the [docs code example](symfony/symfony-docs#6438 (comment)) and [existing pr on the SFEB](sensiolabs/SensioFrameworkExtraBundle#327).With the new example you can do the following:```php// when a User is mandatory, e.g. behind firewallpublic function fooAction(UserInterface $user)// when a User is optional, e.g. where it can be anonymouspublic function barAction(UserInterface $user = null)```This deprecates the `Controller::getUser()` method.I have added it on a priority of 40 so it falls just under the `RequestValueResolver`. This is because it's already used and the initial performance is less of an impact.There was a comment asking if the `controller_argument.value_resolver` tag name wasn't too long. If decided this tag should change before 3.1 is released, I will update it in here.*`RequestValueResolver` contains a small codestyle consistency fix.*Commits-------d341889 Added a SecurityUserValueResolver for controllers
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

3.1

Development

Successfully merging this pull request may close these issues.

8 participants

@linaori@wouterj@fabpot@OskarStark@xabbuh@javiereguiluz@theofidry@HeahDude

[8]ページ先頭

©2009-2025 Movatter.jp