Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8cb1246

Browse files
committed
[Doctrine] Fix #[MapEntity(expr: '...')]
1 parent eeb37c4 commit 8cb1246

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

doctrine.rst

+3-3
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)