Skip to content

Commit a763c43

Browse files
committed
minor #19988 Allow EntityValueResolver to return a list of entities (javiereguiluz)
This PR was merged into the 7.1 branch. Discussion ---------- Allow EntityValueResolver to return a list of entities Fixes #19801. Commits ------- feabd16 [DoctrineBridge] Allow EntityValueResolver to return a list of entities
2 parents 8396cd4 + feabd16 commit a763c43

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

doctrine.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,20 @@ In the expression, the ``repository`` variable will be your entity's
741741
Repository class and any route wildcards - like ``{product_id}`` are
742742
available as variables.
743743

744+
The repository method called in the expression can also return a list of entities.
745+
In that case, update the type of your controller argument::
746+
747+
#[Route('/posts_by/{author_id}')]
748+
public function authorPosts(
749+
#[MapEntity(class: Post::class, expr: 'repository.findBy({"author": author_id}, {}, 10)')]
750+
iterable $posts
751+
): Response {
752+
}
753+
754+
.. versionadded:: 7.1
755+
756+
The mapping of the lists of entities was introduced in Symfony 7.1.
757+
744758
This can also be used to help resolve multiple arguments::
745759

746760
#[Route('/product/{id}/comments/{comment_id}')]

0 commit comments

Comments
 (0)