docgen: add location to accompanying period

This commit is contained in:
Julien Fastré 2022-01-04 23:50:22 +01:00
parent f63afea2ce
commit 78cf817921

View File

@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Serializer\Normalizer; namespace Chill\PersonBundle\Serializer\Normalizer;
use Chill\DocGeneratorBundle\Serializer\Helper\NormalizeNullValueHelper; use Chill\DocGeneratorBundle\Serializer\Helper\NormalizeNullValueHelper;
use Chill\MainBundle\Entity\Address;
use Chill\MainBundle\Entity\Scope; use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Security\Resolver\ScopeResolverDispatcher; use Chill\MainBundle\Security\Resolver\ScopeResolverDispatcher;
@ -65,6 +66,8 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf
'requestorPerson' => Person::class, 'requestorPerson' => Person::class,
'requestorThirdParty' => ThirdParty::class, 'requestorThirdParty' => ThirdParty::class,
'resources' => Collection::class, 'resources' => Collection::class,
'location' => Address::class,
'locationPerson' => Person::class,
]; ];
private ClosingMotiveRender $closingMotiveRender; private ClosingMotiveRender $closingMotiveRender;
@ -104,6 +107,7 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf
$scopes = [$scopes]; $scopes = [$scopes];
} }
$addressContext = array_merge($context, ['docgen:expects' => Address::class, 'groups' => 'docgen:read']);
$dateContext = array_merge($context, ['docgen:expects' => DateTime::class, 'groups' => 'docgen:read']); $dateContext = array_merge($context, ['docgen:expects' => DateTime::class, 'groups' => 'docgen:read']);
$userContext = array_merge($context, ['docgen:expects' => User::class, 'groups' => 'docgen:read']); $userContext = array_merge($context, ['docgen:expects' => User::class, 'groups' => 'docgen:read']);
$participationContext = array_merge($context, ['docgen:expects' => AccompanyingPeriodParticipation::class, 'groups' => 'docgen:read']); $participationContext = array_merge($context, ['docgen:expects' => AccompanyingPeriodParticipation::class, 'groups' => 'docgen:read']);
@ -147,6 +151,10 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf
}, $scopes)), }, $scopes)),
'hasRequestor' => $period->getRequestor() !== null, 'hasRequestor' => $period->getRequestor() !== null,
'requestorKind' => $period->getRequestorKind(), 'requestorKind' => $period->getRequestorKind(),
'hasLocation' => $period->getLocation() !== null,
'hasLocationPerson' => $period->getPersonLocation() !== null,
'locationPerson' => $this->normalizer->normalize($period->getPersonLocation(), $format, array_merge($context, ['docgen:expects' => Person::class])),
'location' => $this->normalizer->normalize($period->getLocation(), $format, $addressContext),
]; ];
} }
@ -162,6 +170,8 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf
'hasRequestorThirdParty' => false, 'hasRequestorThirdParty' => false,
'isClosed' => false, 'isClosed' => false,
'confidential' => false, 'confidential' => false,
'hasLocation' => false,
'hasLocationPerson' => false,
] ]
); );
} }