Skip to content

[DoctrineBridge] Pass User to EntityValueResolver's expression #57358

Open
@seb-jean

Description

@seb-jean

Description

Currently we can do this:

#[Route('/{author_id}', name: 'app_test')]
public function index(
    #[MapEntity(class: Post::class, expr: 'repository.findBy({"author": author_id}, {}, 10)')]
    iterable $posts
): Response {
// ...
}

It would be interesting to be able to integrate the current user into EntityValueResolver's expression

#[Route('/my-posts', name: 'app_my_posts')]
public function index(
    #[MapEntity(class: Post::class, expr: 'repository.findBy({"author": user}, {}, 10)')]
    iterable $posts
): Response {
// ...
}

This will also allow you to modify symfony/demo and use #[MapEntity] for the example below:

https://github.com/symfony/demo/blob/5dd64c8440b3a3b1133bd128babcf3cdf97f0ac1/src/Controller/Admin/BlogController.php#L58-L65

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