Skip to content

Commit acd3fe2

Browse files
committed
feature #18991 Pass Request to EntityValueResolver (alexandre-daubois)
This PR was merged into the 6.4 branch. Discussion ---------- Pass `Request` to EntityValueResolver Fix #18987 Commits ------- 8be44d7 [DoctrineBridge] Pass `Request` to EntityValueResolver
2 parents 6de9b0f + 8be44d7 commit acd3fe2

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)