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

Point that route parameters are also Request attributes#6219

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
sfdumi wants to merge2 commits intosymfony:3.0fromsfdumi:patch-6

Conversation

sfdumi
Copy link
Contributor

Point that route parameters are also Request attributes

Point that route parameters are also Request attributes
@javiereguiluz
Copy link
Member

@sfdumi 👍 I like your proposal because a lot of people are not aware of this. Thank you!

{
// ...
$titleAttribute = $request->attributes->get('title'); // same as $title
Copy link
Contributor

Choose a reason for hiding this comment

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

$titleAttribute is confusing imo, to show this, its enough to write$request->attributes->get('title'); // same as $title

what do you thing@javiereguiluz

Copy link
Member

Choose a reason for hiding this comment

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

I agree with you. We could even split the example in two parts:

// Getting the title via controller argumentspublicfunctionindexAction($page,$title){// ...}// Getting the title via request attributesuseSymfony\Component\HttpFoundation\Request;publicfunctionindexAction(Request$request){$title =$request->attributes->get('title');// ...}

@sfdumi
Copy link
ContributorAuthor

This sounds like a good idea. Should I update the PR?

@@ -7,7 +7,7 @@ How to Pass Extra Information from a Route to a Controller
Parameters inside the ``defaults`` collection don't necessarily have to
match a placeholder in the route ``path``. In fact, you can use the
``defaults`` array to specify extra parameters that will then be accessible as
arguments to your controller:
arguments to your controller, and as attributes of the ``Request`` object:
Copy link
Member

Choose a reason for hiding this comment

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

We change this a bit and only tell the reader that we can access the parameters in the controller:

[...] that will then be accessible in your controller::

@wouterj
Copy link
Member

I like this addition! If you can and agree with them, please update this PR to add the proposed changes.

Separated the Request attributes example from the method argument one.
@sfdumi
Copy link
ContributorAuthor

Updated the PR.

@javiereguiluz
Copy link
Member

👍 this PR looks ready to be merged. Our doc managers can fix some long lines when merging this.

Thanks@sfdumi.

@wouterj
Copy link
Member

👍 (I'm very sorry, the update comment completely slipped under my radar)

xabbuh added a commit that referenced this pull requestMar 11, 2016
…sfdumi)This PR was submitted for the 3.0 branch but it was merged into the 2.3 branch instead (closes#6219).Discussion----------Point that route parameters are also Request attributesPoint that route parameters are also Request attributesCommits-------08aae4e Point that route parameters are also Request attributes
xabbuh added a commit that referenced this pull requestMar 11, 2016
@xabbuh
Copy link
Member

Thank you for these improvements@sfdumi! I have merged them into the2.3 branch.

@xabbuhxabbuh closed thisMar 11, 2016
xabbuh added a commit that referenced this pull requestMar 11, 2016
* 2.3:  [#6219] some tweaks  Point that route parameters are also Request attributes  [#6348] some minor tweaks  [best practices] mostly typos  [#6275] some minor tweaks  [quick tour] mostly typos  remove link-local IPv6 address (fe80::1)  [#6305] move link reference to the bottom  Mention IvoryCKEditorBundle in the Symfony Forms doc  [#6328] minor tweak  Update extension.rst - added caution box for people trying to remove the default file with services definitions  Altered single / multiple inheritance sentence  Replace XLIFF number ids by strings
xabbuh added a commit that referenced this pull requestMar 11, 2016
* 2.7:  [#6219] some tweaks  Point that route parameters are also Request attributes  [#6348] some minor tweaks  [best practices] mostly typos  [#6275] some minor tweaks  [quick tour] mostly typos  remove link-local IPv6 address (fe80::1)  [#6305] move link reference to the bottom  Mention IvoryCKEditorBundle in the Symfony Forms doc  [#6328] minor tweak  Update extension.rst - added caution box for people trying to remove the default file with services definitions  Altered single / multiple inheritance sentence  Replace XLIFF number ids by strings  Rename DunglasApiBundle to ApiPlatform
xabbuh added a commit that referenced this pull requestMar 11, 2016
* 2.8:  [#6219] some tweaks  Point that route parameters are also Request attributes  [#6348] some minor tweaks  [best practices] mostly typos  [#6275] some minor tweaks  [quick tour] mostly typos  remove link-local IPv6 address (fe80::1)  [#6305] move link reference to the bottom  Mention IvoryCKEditorBundle in the Symfony Forms doc  [#6328] minor tweak  Update extension.rst - added caution box for people trying to remove the default file with services definitions  Altered single / multiple inheritance sentence  Replace XLIFF number ids by strings  Rename DunglasApiBundle to ApiPlatform
xabbuh added a commit that referenced this pull requestMar 11, 2016
* 3.0:  [#6219] some tweaks  Point that route parameters are also Request attributes  [#6348] some minor tweaks  [best practices] mostly typos  Fix reference to app folder  [#6275] some minor tweaks  [quick tour] mostly typos  remove link-local IPv6 address (fe80::1)  [#6305] move link reference to the bottom  Mention IvoryCKEditorBundle in the Symfony Forms doc  [#6328] minor tweak  Update extension.rst - added caution box for people trying to remove the default file with services definitions  Altered single / multiple inheritance sentence  Replace XLIFF number ids by strings  Rename DunglasApiBundle to ApiPlatform
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
No milestone
Development

Successfully merging this pull request may close these issues.

5 participants
@sfdumi@javiereguiluz@wouterj@xabbuh@OskarStark

[8]ページ先頭

©2009-2025 Movatter.jp