Skip to content

Commit 286ba1b

Browse files
committed
update from comments
1 parent 23a1f0d commit 286ba1b

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

doctrine.rst

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -875,26 +875,24 @@ it is mandatory to use ``#[MapEntity]`` attributes and this can become cumbersom
875875
Document $document,
876876
): Response
877877
{
878-
// the database queries in this case would be:
878+
// this would result in the following database queries:
879879
// $document = $documentRepository->findOneBy(['id' => 'the id', 'name' => 'the name']);
880880
// $category = $categoryRepository->findOneBy(['slug' => 'the slug']);
881881
}
882882

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::
886884

887885
#[Route('/document/{slug:category}/{id:document}-{name:document}')]
888886
public function showDocument(Document $document, Category $category): Response
889887
{
890-
// the database queries in this case would be:
888+
// this would result in the following database queries:
891889
// $document = $documentRepository->findOneBy(['id' => 'the id', 'name' => 'the name']);
892890
// $category = $categoryRepository->findOneBy(['slug' => 'the slug']);
893891
}
894892

895893
.. versionadded:: 7.1
896894

897-
The mapped route parameters were introduced in Symfony 7.1.
895+
Mapped route parameters were introduced in Symfony 7.1.
898896

899897
But when two properties have the same name, you will catach an error if you try ::
900898

@@ -914,7 +912,7 @@ In this case we have to return to MapEntiy::
914912
Document $document,
915913
): Response
916914
{
917-
// the database queries in this case would be:
915+
// this would result in the following database queries:
918916
// $document = $documentRepository->findOneBy(['id' => 'the id', 'slug' => 'the slug document']);
919917
// $category = $categoryRepository->findOneBy(['slug' => 'the slug category']);
920918
}
@@ -926,7 +924,7 @@ When adding route parameters, you can now define the mapping between the route p
926924
#[Route('/document/{slugCategory:category.slug}/{id:document}-{slugDocument:document.slug}')]
927925
public function showDocument(Document $document, Category $category): Response
928926
{
929-
// the database queries in this case would be:
927+
// this would result in the following database queries:
930928
// $document = $documentRepository->findOneBy(['id' => 'the id', 'slug' => 'the slug document']);
931929
// $category = $categoryRepository->findOneBy(['slug' => 'the slug category']);
932930
}

0 commit comments

Comments
 (0)