From 15ea082543ce142c1bb18b582d64a31d7f39aa9b Mon Sep 17 00:00:00 2001 From: Florian Eisenmenger Date: Wed, 14 Feb 2024 16:42:38 +0100 Subject: [PATCH] small fixes --- src/ApiResource/ContactApi.php | 2 +- src/Mapper/ContactEntityToApiMapper.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ApiResource/ContactApi.php b/src/ApiResource/ContactApi.php index 3e250e5..c8582fa 100644 --- a/src/ApiResource/ContactApi.php +++ b/src/ApiResource/ContactApi.php @@ -41,7 +41,7 @@ use Symfony\Component\Validator\Constraints\NotBlank; security: 'is_granted("ROLE_ADMIN")', ) ], - paginationItemsPerPage: 10, + paginationItemsPerPage: 6, security: 'is_granted("ROLE_USER")', provider: EntityToDtoStateProvider::class, processor: EntityClassDtoStateProcessor::class, diff --git a/src/Mapper/ContactEntityToApiMapper.php b/src/Mapper/ContactEntityToApiMapper.php index a9620e8..02bf6d9 100644 --- a/src/Mapper/ContactEntityToApiMapper.php +++ b/src/Mapper/ContactEntityToApiMapper.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: Contact::class, to: ContactApi::class)] class ContactEntityToApiMapper implements MapperInterface { public function __construct( private MicroMapperInterface $microMapper, + private StorageInterface $storage ) { } @@ -46,7 +48,7 @@ class ContactEntityToApiMapper implements MapperInterface ); $dto->birthday = $entity->getBirthday(); $dto->image = $entity->getImage(); - $dto->imageUrl = $entity->getImage()?->getContentUrl(); + $dto->imageUrl = $entity->getImage() !== null ? $this->storage->resolveUri($entity->getImage(), 'file') : null; $dto->position = $entity->getPosition(); $dto->phone = $entity->getPhone(); $dto->email = $entity->getEmail();