person: deserialise altnames (WIP)

This commit is contained in:
nobohan 2021-11-26 20:38:45 +01:00
parent 780b7db8cb
commit c5acfc9bbc

View File

@ -16,6 +16,7 @@ use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface;
use Chill\MainBundle\Templating\Entity\ChillEntityRenderExtension;
use Chill\PersonBundle\Entity\Household\Household;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Entity\PersonAltName;
use Chill\PersonBundle\Repository\PersonRepository;
use DateTime;
use LogicException;
@ -79,7 +80,7 @@ class PersonJsonNormalizer implements
}
foreach (['firstName', 'lastName', 'phonenumber', 'mobilenumber', 'gender',
'birthdate', 'deathdate', 'center', ]
'birthdate', 'deathdate', 'center', 'altNames']
as $item) {
if (!array_key_exists($item, $data)) {
continue;
@ -135,6 +136,16 @@ class PersonJsonNormalizer implements
break;
case 'altNames':
foreach($data[$item] as $altName){
$object = $this->denormalizer->denormalize($altName, PersonAltName::class, $format, $context);
dump($object); //TODO not working
if ($object instanceof PersonAltName) {
$person->addAltName($object);
}
}
break;
default:
throw new LogicException("item not defined: {$item}");
}