From b43a3d394b71d6429c2c65b564b97f4238cf6196 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 22 Nov 2021 12:41:47 +0100 Subject: [PATCH 1/2] fix circular reference in center normalization --- .../Serializer/Normalizer/PersonJsonNormalizer.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php index 3b42e86db..e09c976fe 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php @@ -20,6 +20,7 @@ namespace Chill\PersonBundle\Serializer\Normalizer; use Chill\MainBundle\Entity\Center; use Chill\MainBundle\Security\Resolver\CenterResolverDispatcher; +use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface; use Chill\PersonBundle\Entity\Household\Household; use Chill\PersonBundle\Entity\Person; use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface; @@ -49,7 +50,7 @@ class PersonJsonNormalizer implements private PersonRepository $repository; - private CenterResolverDispatcher $centerResolverDispatcher; + private CenterResolverManagerInterface $centerResolverDispatcher; use NormalizerAwareTrait; @@ -60,7 +61,7 @@ class PersonJsonNormalizer implements public function __construct( ChillEntityRenderExtension $render, PersonRepository $repository, - CenterResolverDispatcher $centerResolverDispatcher + CenterResolverManagerInterface $centerResolverDispatcher ) { $this->render = $render; $this->repository = $repository; @@ -81,7 +82,7 @@ class PersonJsonNormalizer implements 'lastName' => $person->getLastName(), 'birthdate' => $this->normalizer->normalize($person->getBirthdate()), '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(), 'mobilenumber' => $person->getMobilenumber(), 'altNames' => $this->normalizeAltNames($person->getAltNames()), From 2826e079e8c38df0f4d969f15101225dbbfe06d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 22 Nov 2021 12:59:36 +0100 Subject: [PATCH 2/2] key "centers" for person is an array. key center deprecated --- CHANGELOG.md | 1 + .../vuejs/_components/Entity/PersonRenderBox.vue | 11 +++-------- .../Normalizer/PersonJsonNormalizer.php | 16 ++++++++-------- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a308e03cf..1e5cdc25b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ and this project adheres to * [person] create an accompanying course: add client-side validation if no origin (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/210) * [person] fix bounds for computing current person address: the new address appears immediatly * [docgen] create a normalizer and serializer for normalization on doc format +* [person normalization] the key center is now "centers" and is an array. Empty array if no center ## Test releases diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue index eb7793839..ffb9ef3d4 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue @@ -96,14 +96,9 @@

{{ $t('renderbox.no_data') }}

-
  • - - - +
  • + +
  • diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php index e09c976fe..54c801c4b 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php @@ -50,7 +50,7 @@ class PersonJsonNormalizer implements private PersonRepository $repository; - private CenterResolverManagerInterface $centerResolverDispatcher; + private CenterResolverManagerInterface $centerResolverManager; use NormalizerAwareTrait; @@ -61,11 +61,11 @@ class PersonJsonNormalizer implements public function __construct( ChillEntityRenderExtension $render, PersonRepository $repository, - CenterResolverManagerInterface $centerResolverDispatcher + CenterResolverManagerInterface $centerResolverManager ) { $this->render = $render; $this->repository = $repository; - $this->centerResolverDispatcher = $centerResolverDispatcher; + $this->centerResolverManager = $centerResolverManager; } public function normalize($person, string $format = null, array $context = []) @@ -80,15 +80,15 @@ class PersonJsonNormalizer implements 'text' => $this->render->renderString($person), 'firstName' => $person->getFirstName(), 'lastName' => $person->getLastName(), - 'birthdate' => $this->normalizer->normalize($person->getBirthdate()), - 'deathdate' => $this->normalizer->normalize($person->getDeathdate()), - 'center' => $this->normalizer->normalize($this->centerResolverDispatcher->resolveCenters($person), $format, $context), + 'birthdate' => $this->normalizer->normalize($person->getBirthdate(), $format, $context), + 'deathdate' => $this->normalizer->normalize($person->getDeathdate(), $format, $context), + 'centers' => $this->normalizer->normalize($this->centerResolverManager->resolveCenters($person), $format, $context), 'phonenumber' => $person->getPhonenumber(), 'mobilenumber' => $person->getMobilenumber(), 'altNames' => $this->normalizeAltNames($person->getAltNames()), 'gender' => $person->getGender(), - 'current_household_address' => $this->normalizer->normalize($person->getCurrentHouseholdAddress()), - 'current_household_id' => $household ? $this->normalizer->normalize($household->getId()) : null, + 'current_household_address' => $this->normalizer->normalize($person->getCurrentHouseholdAddress(), $format, $context), + 'current_household_id' => $household ? $this->normalizer->normalize($household->getId(), $format, $context) : null, ]; }