Mam taką encję:
/** * @ApiFilter(BooleanFilter::class, properties={"isActive"}) * @ORM\Entity(repositoryClass=FooRepository::class) */ class Foo { /** * @ORM\Column(type="boolean") */ private bool $isActive = true; // ciach reszty, nie dotyczy problemu }
O ile mnie pamiec nie myli, to przez dataprovider modyfikujesz zapytanie.
Dzięki, faktycznie chodzi o DataProvider.
Manual: https://api-platform.com/docs/core/data-providers/
I rozwiązanie (oczywiście metodę 'findByFieldBar()' trzeba juz sobie samemu ogarnąć w Repository:
<?php namespace App\DataProvider; use ApiPlatform\Core\DataProvider\CollectionDataProviderInterface; use ApiPlatform\Core\DataProvider\RestrictedDataProviderInterface; use App\Entity\Foo; use App\Repository\FooRepository; final class FooCollectionDataProvider implements CollectionDataProviderInterface, RestrictedDataProviderInterface { /** * @var FooRepository */ private FooRepository $fooRepository; public function __construct(FooRepository $fooRepository) { $this->fooRepository = $fooRepository; } public function supports(string $resourceClass, string $operationName = null, http://www.php.net/array $context = []): bool { return Foo::class === $resourceClass; } public function getCollection(string $resourceClass, string $operationName = null) { return $this->fooRepository->findByFieldBar(); } }
Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)