File tree 1 file changed +19
-0
lines changed
1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -1020,6 +1020,25 @@ corresponding ``BlogPost`` object from the database using the slug.
1020
1020
1021
1021
Route parameter mapping was introduced in Symfony 7.1.
1022
1022
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
+
1023
1042
More advanced mappings can be achieved using the ``#[MapEntity] `` attribute.
1024
1043
Check out the :ref: `Doctrine param conversion documentation <doctrine-entity-value-resolver >`
1025
1044
to learn how to customize the database queries used to fetch the object from the route
You can’t perform that action at this time.
0 commit comments