Open
Description
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