Skip to content

Commit 44ea4d5

Browse files
committed
bug #19367 [Doctrine] Fix #[MapEntity(expr: '...')] (Jean-Beru)
This PR was submitted for the 7.1 branch but it was merged into the 6.4 branch instead. Discussion ---------- [Doctrine] Fix #[MapEntity(expr: '...')] Fix symfony/symfony#53236 Commits ------- 8cb1246 [Doctrine] Fix #[MapEntity(expr: '...')]
2 parents eeb37c4 + 8cb1246 commit 44ea4d5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

doctrine.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -751,13 +751,13 @@ the default convention.
751751

752752
If you need to get other information from the request to query the database, you
753753
can also access the request in your expression thanks to the ``request``
754-
variable. Let's say you pass the page limit of a list in a query parameter::
754+
variable. Let's say you want the first or the last comment of a product depending on a query parameter named ``sort``::
755755

756756
#[Route('/product/{id}/comments')]
757757
public function show(
758758
Product $product,
759-
#[MapEntity(expr: 'repository.findBy(["product_id" => id], null, request.query.get("limit", 10)')]
760-
iterable $comments
759+
#[MapEntity(expr: 'repository.findOneBy({"product": id}, {"createdAt": request.query.get("sort", "DESC")})')]
760+
Comment $comment
761761
): Response {
762762
}
763763

0 commit comments

Comments
 (0)