@@ -1006,32 +1006,13 @@ using the request parameters (``slug`` in this case). If no object is found,
1006
1006
Symfony generates a 404 response automatically.
1007
1007
1008
1008
The ``{slug:post} `` syntax maps the route parameter named ``slug `` to the controller
1009
- argument named ``$post ``. It also hints the "param converter" to lookup by slug
1010
- when loading the corresponding ``BlogPost `` object from the database.
1009
+ argument named ``$post ``. It also hints the "param converter" to look up the
1010
+ corresponding ``BlogPost `` object from the database using the slug .
1011
1011
1012
1012
.. versionadded :: 7.1
1013
1013
1014
1014
Route parameter mapping was introduced in Symfony 7.1.
1015
1015
1016
- When more than one entity needs to be derived from route parameters, collisions can happen.
1017
- In the following example, the route tries to define two mappings: one to load an author by
1018
- name, two to load a category by name. But this is not allowed because from the side of the
1019
- route definition, this declares a parameter named "name" twice::
1020
-
1021
- #[Route('/search-book/{name:author}/{name:category}')]
1022
-
1023
- Such routes should instead be defined using the following syntax::
1024
-
1025
- #[Route('/search-book/{authorName:author.name}/{categoryName:category.name}')]
1026
-
1027
- This way, the route parameter names are unique (``authorName `` and ``categoryName ``) and
1028
- the "param converter" can correctly map them to controller arguments (``$author `` and
1029
- ``$category ``), loading them both by their name.
1030
-
1031
- .. versionadded :: 7.3
1032
-
1033
- This more advanced style of route parameter mapping was introduced in Symfony 7.3.
1034
-
1035
1016
More advanced mappings can be achieved using the ``#[MapEntity] `` attribute.
1036
1017
Check out the :ref: `Doctrine param conversion documentation <doctrine-entity-value-resolver >`
1037
1018
to learn how to customize the database queries used to fetch the object from the route
0 commit comments