mirror of
				https://gitlab.com/Chill-Projet/chill-bundles.git
				synced 2025-10-31 01:08:26 +00:00 
			
		
		
		
	Use new gender entity in personDocGenNormalizer
This commit is contained in:
		| @@ -16,6 +16,7 @@ use Chill\DocGeneratorBundle\Serializer\Helper\NormalizeNullValueHelper; | ||||
| use Chill\MainBundle\Entity\Address; | ||||
| use Chill\MainBundle\Entity\Center; | ||||
| use Chill\MainBundle\Entity\Civility; | ||||
| use Chill\MainBundle\Entity\Gender; | ||||
| use Chill\MainBundle\Templating\TranslatableStringHelper; | ||||
| use Chill\PersonBundle\Entity\Household\Household; | ||||
| use Chill\PersonBundle\Entity\Person; | ||||
| @@ -30,7 +31,6 @@ use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; | ||||
| use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface; | ||||
| use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface; | ||||
| use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait; | ||||
| use Symfony\Contracts\Translation\TranslatorInterface; | ||||
|  | ||||
| class PersonDocGenNormalizer implements | ||||
|     ContextAwareNormalizerInterface, | ||||
| @@ -40,7 +40,7 @@ class PersonDocGenNormalizer implements | ||||
|  | ||||
|     private const CIRCULAR_KEY = 'person:circular'; | ||||
|  | ||||
|     public function __construct(private readonly PersonRenderInterface $personRender, private readonly RelationshipRepository $relationshipRepository, private readonly TranslatorInterface $translator, private readonly TranslatableStringHelper $translatableStringHelper, private readonly SummaryBudgetInterface $summaryBudget) {} | ||||
|     public function __construct(private readonly PersonRenderInterface $personRender, private readonly RelationshipRepository $relationshipRepository, private readonly TranslatableStringHelper $translatableStringHelper, private readonly SummaryBudgetInterface $summaryBudget) {} | ||||
|  | ||||
|     public function normalize($person, $format = null, array $context = []) | ||||
|     { | ||||
| @@ -67,6 +67,7 @@ class PersonDocGenNormalizer implements | ||||
|             // when a person reference the same person... take care of circular references | ||||
|             AbstractNormalizer::CIRCULAR_REFERENCE_HANDLER => fn ($object, $format, $context) => $this->normalizer->normalize(null, $format, $context), | ||||
|         ]); | ||||
|         $genderContext = array_merge($context, ['docgen:expects' => Gender::class]); | ||||
|  | ||||
|         if (null === $person) { | ||||
|             return $this->normalizeNullValue($format, $context); | ||||
| @@ -94,7 +95,7 @@ class PersonDocGenNormalizer implements | ||||
|             'age' => (int) $person->getAge(), | ||||
|             'birthdate' => $this->normalizer->normalize($person->getBirthdate(), $format, $dateContext), | ||||
|             'deathdate' => $this->normalizer->normalize($person->getDeathdate(), $format, $dateContext), | ||||
|             'gender' => $this->translator->trans($person->getGender()), | ||||
|             'gender' => $this->normalizer->normalize($person->getGender(), $format, $genderContext), | ||||
|             'maritalStatus' => null !== ($ms = $person->getMaritalStatus()) ? $this->translatableStringHelper->localize($ms->getName()) : '', | ||||
|             'maritalStatusDate' => $this->normalizer->normalize($person->getMaritalStatusDate(), $format, $dateContext), | ||||
|             'maritalStatusComment' => $this->normalizer->normalize($person->getMaritalStatusComment(), $format, $dateContext), | ||||
|   | ||||
		Reference in New Issue
	
	Block a user