8000 [HttpKernel] `MapEntityCollection` concept · Issue #60451 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
[HttpKernel] MapEntityCollection concept #60451
Open
@evgenij-vy

Description

@evgenij-vy

Description

Hi everybody. It seems that Symfony needed a smart resolver for entity collection.
It's concept, and if it is really interesting for the community, I'll continue working.

Now I create PR #60450 for preview

Example

Entity:

class SomeEntity
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column]
    private ?int $id = null;

    #[ORM\Column(length: 255)]
    private ?string $name = null;

    #[ORM\Column(length: 255)]
    private ?string $email = null;

    #[ORM\Column(length: 255)]
    private ?string $gender = null;

   #[ORM\Column()]
   private ?string $car = null;
class QueryStringObject
{
    private ?string $name = null;

    private ?string $email = null;
 
   private ?string $carModel = null;
#[Route(path: '/male_client, method: ['GET'])]
public function __invoke(
    #[MapEntityCollection(
        class: SomeEntity::class,
        queryString: 'queryString',
        queryMapping: ['carModel' => 'car'],
        doctrineParameters: ['gender' => 'male'],
        filters: [
            MyCustomFilter::class,
        ],
        defaultOrdering: ['id' => 'ASC']
    )]
    iterable $collectionEntity,
    #[MapQueryString]
    QueryStringObject $queryString,
)
{
}

So we can easily add a filter by some property or a custom reusable filter like ApiPlatform.
I like attributes, and my goal is to configure as much as possible and write minimal code

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

      0