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

[Routing] Add{foo:bar} syntax to define a mapping between a route parameter and its corresponding request attribute#19869

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

Conversation

alamirault
Copy link
Contributor

…rameter and its corresponding request attribute
Co-authored-by: Oskar Stark <oskarstark@googlemail.com>
Copy link
Member

@javiereguiluzjaviereguiluz left a comment

Choose a reason for hiding this comment

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

Antoine, thanks for this contribution!

@rcsofttech85
Copy link
Contributor

rcsofttech85 commentedMay 8, 2024
edited
Loading

I did not find any example on map entity, you may consider this example below

    #[Route(path:'/profile/{name:name}/{age:age}', name:'profile', methods: ['GET'])]publicfunctionfetchProfile(Profile$profile):Response    {//    }

@alamirault
Copy link
ContributorAuthor

I did not find any example on map entity, you may consider this example below

    #[Route(path: '/profile/{name:name}/{age:age}', name: 'profile', methods: ['GET'])]    public function fetchProfile(Profile $profile): Response    {       //     }

I'm not sure to understand your suggestion, why map name to name and age to age ?

I think the original PR has no direct link with MapEntity ?

@rcsofttech85
Copy link
Contributor

@alamirault The main idea was to improve automapping doctrine entities. Now, automapping of entities in favor of mapped route parameters is deprecated. The code I posted is a working example of entities and route parameters.

{name:name}/{age:age} = > "foo" is the name of the wildcard and "bar" is a property or attribute of the entity.

Here is another simple example:

    #[Route(path:'/product/{product_slug:slug}', name:'product', methods: ['GET'])]publicfunctiongetProduct(Product$product):Response    {//    }

@nicolas-grekas could you please ensure it's correct.

~~~~~~~~~~~~~~~~~~

By default, the route parameter (``{slug}`` for example) is the name of the argument
injected to the controller method (``$slug``).
Copy link
Member

@nicolas-grekasnicolas-grekasMay 10, 2024
edited
Loading

Choose a reason for hiding this comment

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

I think we need to be more precise. There are two steps between parameters and controllers:
The routing side does only one thing: populate a parameter named _route_mapping.
Then a listener will use that to map parameters to request attributes.
And then argument resolvers will map to controllers.
Explaining the steps can empower readers.
Not sure what exactly how we should say all this :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the info. I just wanted to help with the code which works with this new feature.. :)

javiereguiluz added a commit that referenced this pull requestMay 20, 2025
…-grekas)This PR was merged into the 7.2 branch.Discussion----------[Routing] Tell about `{foo:bar}` mapping syntaxFix#20806Fix#19846Fix#19848Replaces#19869Replaces#20812Commits-------e591c59 [Routing] Tell about {foo:bar} mapping syntax
@javiereguiluz
Copy link
Member

Antoine, thanks a lot for this contribution. Sadly we have to close it without merging because we came up with an alternative PR (#20956) that also fixed other minor issues in routing docs. Sorry!

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@rcsofttech85rcsofttech85rcsofttech85 left review comments

@OskarStarkOskarStarkAwaiting requested review from OskarStark

@javiereguiluzjaviereguiluzAwaiting requested review from javiereguiluz

Assignees
No one assigned
Projects
None yet
Milestone
7.1
Development

Successfully merging this pull request may close these issues.

[Routing] Add{foo:bar} syntax to define a mapping between a route pa…
6 participants
@alamirault@rcsofttech85@javiereguiluz@nicolas-grekas@OskarStark@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp