@@ -875,26 +875,24 @@ it is mandatory to use ``#[MapEntity]`` attributes and this can become cumbersom
875
875
Document $document,
876
876
): Response
877
877
{
878
- // the database queries in this case would be :
878
+ // this would result in the following database queries :
879
879
// $document = $documentRepository->findOneBy(['id' => 'the id', 'name' => 'the name']);
880
880
// $category = $categoryRepository->findOneBy(['slug' => 'the slug']);
881
881
}
882
882
883
- As an alternative, you can also use Mapped Route Parameters.
884
-
885
- When adding route parameters, you can now define the mapping between the route parameter and the controller argument::
883
+ By using mapped route parameters, you can define the mapping between the route parameter and the controller argument::
886
884
887
885
#[Route('/document/{slug:category}/{id:document}-{name:document}')]
888
886
public function showDocument(Document $document, Category $category): Response
889
887
{
890
- // the database queries in this case would be :
888
+ // this would result in the following database queries :
891
889
// $document = $documentRepository->findOneBy(['id' => 'the id', 'name' => 'the name']);
892
890
// $category = $categoryRepository->findOneBy(['slug' => 'the slug']);
893
891
}
894
892
895
893
.. versionadded :: 7.1
896
894
897
- The mapped route parameters were introduced in Symfony 7.1.
895
+ Mapped route parameters were introduced in Symfony 7.1.
898
896
899
897
But when two properties have the same name, you will catach an error if you try ::
900
898
@@ -914,7 +912,7 @@ In this case we have to return to MapEntiy::
914
912
Document $document,
915
913
): Response
916
914
{
917
- // the database queries in this case would be :
915
+ // this would result in the following database queries :
918
916
// $document = $documentRepository->findOneBy(['id' => 'the id', 'slug' => 'the slug document']);
919
917
// $category = $categoryRepository->findOneBy(['slug' => 'the slug category']);
920
918
}
@@ -926,7 +924,7 @@ When adding route parameters, you can now define the mapping between the route p
926
924
#[Route('/document/{slugCategory:category.slug}/{id:document}-{slugDocument:document.slug}')]
927
925
public function showDocument(Document $document, Category $category): Response
928
926
{
929
- // the database queries in this case would be :
927
+ // this would result in the following database queries :
930
928
// $document = $documentRepository->findOneBy(['id' => 'the id', 'slug' => 'the slug document']);
931
929
// $category = $categoryRepository->findOneBy(['slug' => 'the slug category']);
932
930
}
0 commit comments