mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-30 10:29:42 +00:00
Remove serializer.yaml
configuration, update PersonJsonNormalizer
and PersonJsonDenormalizer
for improved logic handling, adjust type hints in closures, and rename id
to definition_id
in PersonIdentifierWorkerNormalizer
.
This commit is contained in:
@@ -62,7 +62,7 @@ final class PersonJsonDenormalizer implements DenormalizerInterface, Denormalize
|
||||
$person->setMobilenumber($this->denormalizer->denormalize($data['mobilenumber'], PhoneNumber::class, $format, $context));
|
||||
}
|
||||
|
||||
if (\array_key_exists('gender', $data)) {
|
||||
if (\array_key_exists('gender', $data) && null !== $data['gender']) {
|
||||
$gender = $this->denormalizer->denormalize($data['gender'], Gender::class, $format, []);
|
||||
$person->setGender($gender);
|
||||
}
|
||||
@@ -93,7 +93,7 @@ final class PersonJsonDenormalizer implements DenormalizerInterface, Denormalize
|
||||
$altNameKey = $altNameData['key'];
|
||||
$altNameValue = $altNameData['value'];
|
||||
|
||||
$altName = $person->getAltNames()->findFirst(fn (PersonAltName $personAltName) => $personAltName->getKey() === $altNameKey);
|
||||
$altName = $person->getAltNames()->findFirst(fn (int $key, PersonAltName $personAltName) => $personAltName->getKey() === $altNameKey);
|
||||
if (null === $altName) {
|
||||
$altName = new PersonAltName();
|
||||
$person->addAltName($altName);
|
||||
@@ -117,7 +117,7 @@ final class PersonJsonDenormalizer implements DenormalizerInterface, Denormalize
|
||||
|
||||
$worker = $this->personIdentifierManager->buildWorkerByPersonIdentifierDefinition($definitionId);
|
||||
|
||||
$personIdentifier = $person->getIdentifiers()->findFirst(fn (PersonIdentifier $personIdentifier) => $personIdentifier->getId() === $definitionId);
|
||||
$personIdentifier = $person->getIdentifiers()->findFirst(fn (int $key, PersonIdentifier $personIdentifier) => $personIdentifier->getId() === $definitionId);
|
||||
if (null === $personIdentifier) {
|
||||
$personIdentifier = new PersonIdentifier($worker->getDefinition());
|
||||
$person->addIdentifier($personIdentifier);
|
||||
@@ -132,7 +132,7 @@ final class PersonJsonDenormalizer implements DenormalizerInterface, Denormalize
|
||||
$person->setEmail($data['email']);
|
||||
}
|
||||
|
||||
if (\array_key_exists('civility', $data)) {
|
||||
if (\array_key_exists('civility', $data) && null !== $data['civility']) {
|
||||
$civility = $this->denormalizer->denormalize($data['civility'], Civility::class, $format, []);
|
||||
$person->setCivility($civility);
|
||||
}
|
||||
|
@@ -21,11 +21,12 @@ use Doctrine\Common\Collections\Collection;
|
||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
|
||||
/**
|
||||
* Serialize a Person entity.
|
||||
*/
|
||||
class PersonJsonNormalizer implements NormalizerAwareInterface
|
||||
class PersonJsonNormalizer implements NormalizerAwareInterface, NormalizerInterface
|
||||
{
|
||||
use NormalizerAwareTrait;
|
||||
|
||||
|
Reference in New Issue
Block a user