Skip to content

[Doctrine] Fix #[MapEntity(expr: '...')] #19367

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions doctrine.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
}

Expand Down