From 8cb124618ae25d6cd712e552f7e5bb2295ba5435 Mon Sep 17 00:00:00 2001 From: "hubert.lenoir" Date: Tue, 2 Jan 2024 14:56:34 +0100 Subject: [PATCH] [Doctrine] Fix #[MapEntity(expr: '...')] --- doctrine.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doctrine.rst b/doctrine.rst index e1d91969e92..b3e202f5792 100644 --- a/doctrine.rst +++ b/doctrine.rst @@ -751,13 +751,13 @@ the default convention. If you need to get other information from the request to query the database, you can also access the request in your expression thanks to the ``request`` -variable. Let's say you pass the page limit of a list in a query parameter:: +variable. Let's say you want the first or the last comment of a product depending on a query parameter named ``sort``:: #[Route('/product/{id}/comments')] public function show( Product $product, - #[MapEntity(expr: 'repository.findBy(["product_id" => id], null, request.query.get("limit", 10)')] - iterable $comments + #[MapEntity(expr: 'repository.findOneBy({"product": id}, {"createdAt": request.query.get("sort", "DESC")})')] + Comment $comment ): Response { }