src/Contact/Serializer/Normalizer/ContactRelationshipCompanyContactPersonNormalizer.php line 57
<?phpdeclare(strict_types=1);/*** Copyright (c) 2021 TECLA Consulting Group oü.* All rights reserved.** This unpublished material is proprietary to TECLA Consulting Group oü.* All rights reserved. The methods and* techniques described herein are considered trade secrets* and/or confidential. Reproduction or distribution, in whole* or in part, is forbidden except by express written permission* of TECLA Consulting Group oü.** @author Matúš Sýkorjak <matus@tecla.no>* @copyright 2021 TECLA Consulting Group oü*/namespace App\Contact\Serializer\Normalizer;use App\Contact\Model\ContactRelationshipCompanyContactPersonInterface;use App\Core\Serializer\Normalizer\AttributeAwareNormalizerTrait;use Symfony\Component\Routing\Generator\UrlGeneratorInterface;use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface;use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;use Symfony\Component\Serializer\Normalizer\NormalizerInterface;final class ContactRelationshipCompanyContactPersonNormalizer implements ContextAwareNormalizerInterface, CacheableSupportsMethodInterface{use AttributeAwareNormalizerTrait;private NormalizerInterface $normalizer;private UrlGeneratorInterface $urlGenerator;public function __construct(NormalizerInterface $normalizer, UrlGeneratorInterface $urlGenerator){$this->normalizer = $normalizer;$this->urlGenerator = $urlGenerator;}public function normalize($object, string $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null{$data = $this->normalizer->normalize($object, $format, $context);if (true === $this->shouldSerializeAttribute($data, ContactRelationshipCompanyContactPersonInterface::ATTR_IS_DEFAULT, $context)) {$this->normalizeIsDefault($object, $data);}if (true === $this->shouldSerializeAttribute($data, ContactRelationshipCompanyContactPersonInterface::ATTR__LINKS, $context)) {$this->normalize_Links($object, $data);}return $data;}public function supportsNormalization($data, string $format = null, array $context = []): bool{return $data instanceof ContactRelationshipCompanyContactPersonInterface;}public function hasCacheableSupportsMethod(): bool{return __CLASS__ === static::class;}private function normalizeIsDefault(ContactRelationshipCompanyContactPersonInterface $relationship, array &$data): void{$data[ContactRelationshipCompanyContactPersonInterface::ATTR_IS_DEFAULT] = $relationship === $relationship->getCompany()->getDefaultRelationshipCompanyContactPerson();}private function normalize_Links(ContactRelationshipCompanyContactPersonInterface $relationship, array &$data): void{$data[ContactRelationshipCompanyContactPersonInterface::ATTR__LINKS] = ['ajax' => ['edit' => $this->urlGenerator->generate('app.contact.ajax.contact_relationship_contact_person.edit', ['contactId' => $relationship->getCompany()->getId(),'relationshipId' => $relationship->getId(),]),'remove' => $this->urlGenerator->generate('app.contact.ajax.contact_relationship_contact_person.remove', ['contactId' => $relationship->getCompany()->getId(),'relationshipId' => $relationship->getId(),]),],];}}