Skip to content

Commit d71927f

Browse files
committed
[Routing] Readd the 7.3 docs about advance param mapping
1 parent 4a93223 commit d71927f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

routing.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,25 @@ corresponding ``BlogPost`` object from the database using the slug.
10201020

10211021
Route parameter mapping was introduced in Symfony 7.1.
10221022

1023+
When mapping multiple entities from route parameters, name collisions can occur.
1024+
In this example, the route tries to define two mappings: one for an author and one
1025+
for a category; both using the same ``name`` parameter. This isn't allowed because
1026+
the route ends up declaring ``name`` twice::
1027+
1028+
#[Route('/search-book/{name:author}/{name:category}')]
1029+
1030+
Such routes should instead be defined using the following syntax::
1031+
1032+
#[Route('/search-book/{authorName:author.name}/{categoryName:category.name}')]
1033+
1034+
This way, the route parameter names are unique (``authorName`` and ``categoryName``),
1035+
and the "param converter" can correctly map them to controller arguments (``$author``
1036+
and ``$category``), loading them both by their name.
1037+
1038+
.. versionadded:: 7.3
1039+
1040+
This more advanced style of route parameter mapping was introduced in Symfony 7.3.
1041+
10231042
More advanced mappings can be achieved using the ``#[MapEntity]`` attribute.
10241043
Check out the :ref:`Doctrine param conversion documentation <doctrine-entity-value-resolver>`
10251044
to learn how to customize the database queries used to fetch the object from the route

0 commit comments

Comments
 (0)