@@ -867,7 +867,7 @@ Mapped Route Parameters
867
867
When many route parameters are used to find more than one entity,
868
868
it is mandatory to use ``#[MapEntity] `` attributes and this can become cumbersome::
869
869
870
- #[Route('/document/{slug}/{id}-{name}/ ')]
870
+ #[Route('/document/{slug}/{id}-{name}')]
871
871
public function showDocument(
872
872
#[MapEntity(mapping: ['slug' => 'slug'])]
873
873
Category $category,
@@ -884,7 +884,7 @@ As an alternative, you can also use Mapped Route Parameters.
884
884
885
885
When adding route parameters, you can now define the mapping between the route parameter and the controller argument::
886
886
887
- #[Route('/document/{slug:category}/{id:document}-{name:document}/ ')]
887
+ #[Route('/document/{slug:category}/{id:document}-{name:document}')]
888
888
public function showDocument(Document $document, Category $category): Response
889
889
{
890
890
// the database queries in this case would be:
@@ -894,19 +894,19 @@ When adding route parameters, you can now define the mapping between the route p
894
894
895
895
.. versionadded :: 7.1
896
896
897
- The `` Mapped Route Parameters `` was introduced in Symfony 7.1.
897
+ The Mapped Route Parameters was introduced in Symfony 7.1.
898
898
899
899
But when two properties have the same name, you will catach an error if you try ::
900
900
901
- #[Route('/document/{slug:category}/{id:document}-{slug:document}/ ')]
901
+ #[Route('/document/{slug:category}/{id:document}-{slug:document}')]
902
902
public function showDocument(Document $document, Category $category): Response
903
903
{
904
904
// category entity and document entity have the same property ``slug`` but in the route_parameters we can't have two ``slug`` arguments.
905
905
}
906
906
907
907
In this case we have to return to MapEntiy::
908
908
909
- #[Route('/document/{slugCategory}/{id}-{slugDocument}/ ')]
909
+ #[Route('/document/{slugCategory}/{id}-{slugDocument}')]
910
910
public function showDocument(
911
911
#[MapEntity(mapping: ['slugCategory' => 'slug'])]
912
912
Category $category
@@ -919,11 +919,11 @@ In this case we have to return to MapEntiy::
919
919
// $category = $categoryRepository->findOneBy(['slug' => 'the slug category']);
920
920
}
921
921
922
- As an alternative, you can use `` Aliased Mapped Route Parameters `` .
922
+ As an alternative, you can use Aliased Mapped Route Parameters.
923
923
924
924
When adding route parameters, you can now define the mapping between the route parameter and the controller argument with an alias::
925
925
926
- #[Route('/document/{slugCategory:category.slug}/{id:document}-{slugDocument:document.slug}/ ')]
926
+ #[Route('/document/{slugCategory:category.slug}/{id:document}-{slugDocument:document.slug}')]
927
927
public function showDocument(Document $document, Category $category): Response
928
928
{
929
929
// the database queries in this case would be:
@@ -937,7 +937,7 @@ In this case, _route_mapping keys will be slugCategory and slugDocument, and use
937
937
938
938
.. versionadded :: 7.3
939
939
940
- The `` Aliased Mapped Route Parameters `` was introduced in Symfony 7.3.
940
+ The Aliased Mapped Route Parameters was introduced in Symfony 7.3.
941
941
942
942
Updating an Object
943
943
------------------
0 commit comments