vue_accourse: adding current_household link on associated_persons

This commit is contained in:
2021-09-06 15:05:08 +02:00
parent 1262d8cc16
commit 93c08f7e18
5 changed files with 37 additions and 12 deletions

View File

@@ -19,6 +19,7 @@
namespace Chill\PersonBundle\Serializer\Normalizer;
use Chill\MainBundle\Entity\Center;
use Chill\PersonBundle\Entity\Household\Household;
use Chill\PersonBundle\Entity\Person;
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait;
@@ -61,6 +62,9 @@ class PersonNormalizer implements
public function normalize($person, string $format = null, array $context = array())
{
/** @var Household $household */
$household = $person->getCurrentHousehold();
/** @var Person $person */
return [
'type' => 'person',
@@ -76,6 +80,7 @@ class PersonNormalizer implements
'gender' => $person->getGender(),
'gender_numeric' => $person->getGenderNumeric(),
'current_household_address' => $this->normalizer->normalize($person->getCurrentHouseholdAddress()),
'current_household_id' => $household ? $this->normalizer->normalize($household->getId()) : null,
];
}
@@ -89,7 +94,7 @@ class PersonNormalizer implements
return $r;
}
public function supportsNormalization($data, string $format = null): bool
{