mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
person: fix altname denormalisation
This commit is contained in:
@@ -138,10 +138,14 @@ class PersonJsonNormalizer implements
|
||||
|
||||
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);
|
||||
$oldAltName = $person->getAltNames()->filter(function (PersonAltName $n) use ($altName) { return $n->getKey() === $altName['key']; })->first();
|
||||
if (false === $oldAltName) {
|
||||
$newAltName = new PersonAltName();
|
||||
$newAltName->setKey($altName['key']);
|
||||
$newAltName->setLabel($altName['label']);
|
||||
$person->addAltName($newAltName);
|
||||
} else {
|
||||
$oldAltName->setLabel($altName['label']);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
Reference in New Issue
Block a user