Skip to content

Commit 8be44d7

Browse files
[DoctrineBridge] Pass Request to EntityValueResolver
1 parent baedc81 commit 8be44d7

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

doctrine.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,23 @@ In the example above, the ``$product`` argument is handled automatically,
746746
but ``$comment`` is configured with the attribute since they cannot both follow
747747
the default convention.
748748

749+
If you need to get other information from the request to query the database, you
750+
can also access to the request in your expression thanks to the ``request``
751+
variable. Let's say you pass the page limit of a list in a query parameter::
752+
753+
#[Route('/product/{id}/comments')]
754+
public function show(
755+
Product $product,
756+
#[MapEntity(expr: 'repository.findBy(["product_id" => id], null, request.query.get("limit", 10)')]
757+
iterable $comments
758+
): Response {
759+
}
760+
761+
.. versionadded:: 6.4
762+
763+
The support for the ``request`` variable in expressions was introduced
764+
in Symfony 6.4.
765+
749766
MapEntity Options
750767
~~~~~~~~~~~~~~~~~
751768

0 commit comments

Comments
 (0)