Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.2k
[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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
…rameter and its corresponding request attribute
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Oskar Stark <oskarstark@googlemail.com>
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.
Antoine, thanks for this contribution!
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
rcsofttech85 commentedMay 8, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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 {// } |
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 ? |
@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``). |
nicolas-grekasMay 10, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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 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 :)
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.
Thanks for the info. I just wanted to help with the code which works with this new feature.. :)
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! |
Fix#19846