[Routing] Add `{foo:bar}` syntax to define a mapping between a route parameter and its corresponding request attribute
Fix https://github.com/symfony/symfony-docs/issues/19846
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 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 ?
@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'])]
public function getProduct(Product $product): Response
{
//
}
@nicolas-grekas could you please ensure it's correct.