mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Take null value for gender into account and user Interface for translatableStringHelper
This commit is contained in:
parent
0b22250dd5
commit
f4f5153ed0
@ -12,7 +12,7 @@ declare(strict_types=1);
|
|||||||
namespace Chill\PersonBundle\Serializer\Normalizer;
|
namespace Chill\PersonBundle\Serializer\Normalizer;
|
||||||
|
|
||||||
use Chill\MainBundle\Entity\Gender;
|
use Chill\MainBundle\Entity\Gender;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||||
use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
|
use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
|
||||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
|
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
|
||||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
|
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
|
||||||
@ -21,7 +21,7 @@ class GenderDocGenNormalizer implements ContextAwareNormalizerInterface, Normali
|
|||||||
{
|
{
|
||||||
use NormalizerAwareTrait;
|
use NormalizerAwareTrait;
|
||||||
|
|
||||||
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper) {}
|
public function __construct(private readonly TranslatableStringHelperInterface $translatableStringHelper) {}
|
||||||
|
|
||||||
public function supportsNormalization($data, ?string $format = null, array $context = [])
|
public function supportsNormalization($data, ?string $format = null, array $context = [])
|
||||||
{
|
{
|
||||||
|
@ -95,7 +95,7 @@ class PersonDocGenNormalizer implements
|
|||||||
'age' => (int) $person->getAge(),
|
'age' => (int) $person->getAge(),
|
||||||
'birthdate' => $this->normalizer->normalize($person->getBirthdate(), $format, $dateContext),
|
'birthdate' => $this->normalizer->normalize($person->getBirthdate(), $format, $dateContext),
|
||||||
'deathdate' => $this->normalizer->normalize($person->getDeathdate(), $format, $dateContext),
|
'deathdate' => $this->normalizer->normalize($person->getDeathdate(), $format, $dateContext),
|
||||||
'gender' => $this->translatableStringHelper->localize($person->getGender()->getLabel()),
|
'gender' => null !== ($g = $person->getGender()) ? $this->translatableStringHelper->localize($g->getLabel()) : '',
|
||||||
'genderEntity' => $this->normalizer->normalize($person->getGender(), $format, $genderContext),
|
'genderEntity' => $this->normalizer->normalize($person->getGender(), $format, $genderContext),
|
||||||
'maritalStatus' => null !== ($ms = $person->getMaritalStatus()) ? $this->translatableStringHelper->localize($ms->getName()) : '',
|
'maritalStatus' => null !== ($ms = $person->getMaritalStatus()) ? $this->translatableStringHelper->localize($ms->getName()) : '',
|
||||||
'maritalStatusDate' => $this->normalizer->normalize($person->getMaritalStatusDate(), $format, $dateContext),
|
'maritalStatusDate' => $this->normalizer->normalize($person->getMaritalStatusDate(), $format, $dateContext),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user