symfony / demo

Symfony Demo Application
https://symfony.com/
MIT License
2.46k stars 1.61k forks source link

Use MapEntity #1483

Closed seb-jean closed 8 months ago

seb-jean commented 8 months ago

Hi,

I would like to simplify the controller by adding MapEntity but I encounter the error below:

Controller "App\Controller\Admin\BlogController::index" requires that you provide a value for the "$authorPosts" argument. Either the argument is nullable and no null value has been provided, no default value has been provided or there is a non-optional argument after this one.

I use Symfony docs : https://symfony.com/doc/current/doctrine.html#fetch-via-an-expression:

#[Route('/product/{id}/comments')]
public function show(
    Product $product,
    #[MapEntity(expr: 'repository.findBy(["product_id" => id], null, request.query.get("limit", 10)')]
    iterable $comments
): Response {
}

Could you help me finalize the PR?

EDIT

This PR is a reproducer for

xabbuh commented 8 months ago

I guess we can close here now after symfony/symfony#53236