Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[DoctrineBridge] MapEntity with multiple results #53236

Closed
symfony/symfony-docs
#19367
@seb-jean

Description

@seb-jean

Symfony version(s) affected

7.0.1

Description

I use the following code but I meet an error

#[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 {
}

Error is:
Controller "App\Controller\ProductController" requires that you provide a value for the "$comments" 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.

How to reproduce

#[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 {
}

Possible Solution

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions