fix circular reference in center normalization

This commit is contained in:
Julien Fastré 2021-11-22 12:41:47 +01:00
parent fe3d4e1f0a
commit b43a3d394b

View File

@ -20,6 +20,7 @@ namespace Chill\PersonBundle\Serializer\Normalizer;
use Chill\MainBundle\Entity\Center; use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcher; use Chill\MainBundle\Security\Resolver\CenterResolverDispatcher;
use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface;
use Chill\PersonBundle\Entity\Household\Household; use Chill\PersonBundle\Entity\Household\Household;
use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person;
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface; use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
@ -49,7 +50,7 @@ class PersonJsonNormalizer implements
private PersonRepository $repository; private PersonRepository $repository;
private CenterResolverDispatcher $centerResolverDispatcher; private CenterResolverManagerInterface $centerResolverDispatcher;
use NormalizerAwareTrait; use NormalizerAwareTrait;
@ -60,7 +61,7 @@ class PersonJsonNormalizer implements
public function __construct( public function __construct(
ChillEntityRenderExtension $render, ChillEntityRenderExtension $render,
PersonRepository $repository, PersonRepository $repository,
CenterResolverDispatcher $centerResolverDispatcher CenterResolverManagerInterface $centerResolverDispatcher
) { ) {
$this->render = $render; $this->render = $render;
$this->repository = $repository; $this->repository = $repository;
@ -81,7 +82,7 @@ class PersonJsonNormalizer implements
'lastName' => $person->getLastName(), 'lastName' => $person->getLastName(),
'birthdate' => $this->normalizer->normalize($person->getBirthdate()), 'birthdate' => $this->normalizer->normalize($person->getBirthdate()),
'deathdate' => $this->normalizer->normalize($person->getDeathdate()), 'deathdate' => $this->normalizer->normalize($person->getDeathdate()),
'center' => $this->normalizer->normalize($this->centerResolverDispatcher->resolveCenter($person)), 'center' => $this->normalizer->normalize($this->centerResolverDispatcher->resolveCenters($person), $format, $context),
'phonenumber' => $person->getPhonenumber(), 'phonenumber' => $person->getPhonenumber(),
'mobilenumber' => $person->getMobilenumber(), 'mobilenumber' => $person->getMobilenumber(),
'altNames' => $this->normalizeAltNames($person->getAltNames()), 'altNames' => $this->normalizeAltNames($person->getAltNames()),