diff --git a/openapi.yaml b/openapi.yaml index 6493881..3e9679d 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -64,6 +64,32 @@ paths: style: form explode: false allowReserved: false + - + name: partner + in: query + description: '' + required: false + deprecated: false + allowEmptyValue: true + schema: + type: string + style: form + explode: false + allowReserved: false + - + name: 'partner[]' + in: query + description: '' + required: false + deprecated: false + allowEmptyValue: true + schema: + type: array + items: + type: string + style: form + explode: true + allowReserved: false deprecated: false post: operationId: api_contacts_post diff --git a/src/ApiResource/ContactApi.php b/src/ApiResource/ContactApi.php index ea3dac5..3e250e5 100644 --- a/src/ApiResource/ContactApi.php +++ b/src/ApiResource/ContactApi.php @@ -7,7 +7,9 @@ namespace App\ApiResource; +use ApiPlatform\Doctrine\Orm\Filter\SearchFilter; use ApiPlatform\Doctrine\Orm\State\Options; +use ApiPlatform\Metadata\ApiFilter; use ApiPlatform\Metadata\ApiProperty; use ApiPlatform\Metadata\ApiResource; use App\Entity\Contact; @@ -45,7 +47,7 @@ use Symfony\Component\Validator\Constraints\NotBlank; processor: EntityClassDtoStateProcessor::class, stateOptions: new Options(entityClass: Contact::class), )] - +#[ApiFilter(SearchFilter::class, properties: ['partner' => 'exact'])] class ContactApi { #[ApiProperty(readable: false, writable: false, identifier: true)] diff --git a/src/Mapper/ContactEntityToApiMapper.php b/src/Mapper/ContactEntityToApiMapper.php index 2ce595b..a9620e8 100644 --- a/src/Mapper/ContactEntityToApiMapper.php +++ b/src/Mapper/ContactEntityToApiMapper.php @@ -46,7 +46,7 @@ class ContactEntityToApiMapper implements MapperInterface ); $dto->birthday = $entity->getBirthday(); $dto->image = $entity->getImage(); - $dto->imageUrl = $entity->getImage()?->getFilePath(); + $dto->imageUrl = $entity->getImage()?->getContentUrl(); $dto->position = $entity->getPosition(); $dto->phone = $entity->getPhone(); $dto->email = $entity->getEmail(); diff --git a/src/Mapper/PartnerEntityToApiMapper.php b/src/Mapper/PartnerEntityToApiMapper.php index ae23113..1b8b655 100644 --- a/src/Mapper/PartnerEntityToApiMapper.php +++ b/src/Mapper/PartnerEntityToApiMapper.php @@ -9,12 +9,14 @@ use App\Entity\Partner; use Symfonycasts\MicroMapper\AsMapper; use Symfonycasts\MicroMapper\MapperInterface; use Symfonycasts\MicroMapper\MicroMapperInterface; +use Vich\UploaderBundle\Storage\StorageInterface; #[AsMapper(from: Partner::class, to: PartnerApi::class)] class PartnerEntityToApiMapper implements MapperInterface { public function __construct( - private MicroMapperInterface $microMapper + private MicroMapperInterface $microMapper, + private StorageInterface $storage ) { } @@ -45,7 +47,7 @@ class PartnerEntityToApiMapper implements MapperInterface $dto->country = $entity->getCountry(); $dto->website = $entity->getWebsite(); $dto->logo = $entity->getLogo(); - $dto->logoUrl = $entity->getLogo()?->getFilePath(); + $dto->logoUrl = $entity->getLogo() !== null ? $this->storage->resolveUri($entity->getLogo(), 'file') : null; $dto->createdAt = $entity->getCreatedAt(); $dto->contacts = array_map(function(Contact $contact) { return $this->microMapper->map($contact, ContactApi::class, [