|
|
|
@@ -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, [ |
|
|
|
|