diff --git a/src/ApiResource/PartnerApi.php b/src/ApiResource/PartnerApi.php index 9173afc..2b4bb68 100644 --- a/src/ApiResource/PartnerApi.php +++ b/src/ApiResource/PartnerApi.php @@ -101,4 +101,10 @@ class PartnerApi */ #[ApiProperty(writable: false)] public array $contacts = []; + + /** + * @var array + */ + #[ApiProperty(writable: false)] + public array $partnerProducts = []; } \ No newline at end of file diff --git a/src/Mapper/PartnerEntityToApiMapper.php b/src/Mapper/PartnerEntityToApiMapper.php index 3a7b7e2..c932b48 100644 --- a/src/Mapper/PartnerEntityToApiMapper.php +++ b/src/Mapper/PartnerEntityToApiMapper.php @@ -4,10 +4,12 @@ namespace App\Mapper; use App\ApiResource\ContactApi; use App\ApiResource\PartnerApi; +use App\ApiResource\PartnerProductApi; use App\ApiResource\PostingApi; use App\ApiResource\UserApi; use App\Entity\Contact; use App\Entity\Partner; +use App\Entity\PartnerProduct; use App\Entity\Posting; use App\Service\FileUrlService; use Symfonycasts\MicroMapper\AsMapper; @@ -63,11 +65,19 @@ class PartnerEntityToApiMapper implements MapperInterface MicroMapperInterface::MAX_DEPTH => 1, ]); }, $entity->getPostings()->getValues()); + $dto->contacts = array_map(function(Contact $contact) { return $this->microMapper->map($contact, ContactApi::class, [ MicroMapperInterface::MAX_DEPTH => 1, ]); }, $entity->getContacts()->getValues()); + + $dto->partnerProducts = array_map(function(PartnerProduct $contact) { + return $this->microMapper->map($contact, PartnerProductApi::class, [ + MicroMapperInterface::MAX_DEPTH => 1, + ]); + }, $entity->getPartnerProducts()->getValues()); + return $dto; } }