mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
Create gender API and adjust serialization of gender property
This commit is contained in:
@@ -24,6 +24,12 @@ const getCivilities = () =>
|
||||
throw Error('Error with request resource response');
|
||||
});
|
||||
|
||||
const getGenders = () =>
|
||||
fetch('/api/1.0/main/gender.json').then(response => {
|
||||
if (response.ok) { return response.json(); }
|
||||
throw Error('Error with request resource response');
|
||||
});
|
||||
|
||||
const getCentersForPersonCreation = () => makeFetch('GET', '/api/1.0/person/creation/authorized-centers', null);
|
||||
|
||||
/*
|
||||
@@ -67,6 +73,7 @@ export {
|
||||
getPerson,
|
||||
getPersonAltNames,
|
||||
getCivilities,
|
||||
getGenders,
|
||||
postPerson,
|
||||
patchPerson
|
||||
};
|
||||
|
@@ -13,6 +13,7 @@ namespace Chill\PersonBundle\Serializer\Normalizer;
|
||||
|
||||
use Chill\MainBundle\Entity\Center;
|
||||
use Chill\MainBundle\Entity\Civility;
|
||||
use Chill\MainBundle\Entity\Gender;
|
||||
use Chill\MainBundle\Phonenumber\PhoneNumberHelperInterface;
|
||||
use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface;
|
||||
use Chill\MainBundle\Templating\Entity\ChillEntityRenderExtension;
|
||||
@@ -112,7 +113,9 @@ class PersonJsonNormalizer implements DenormalizerAwareInterface, NormalizerAwar
|
||||
break;
|
||||
|
||||
case 'gender':
|
||||
$person->setGender($data[$item]);
|
||||
$gender = $this->denormalizer->denormalize($data[$item], Gender::class, $format, []);
|
||||
|
||||
$person->setGender($gender);
|
||||
|
||||
break;
|
||||
|
||||
@@ -199,7 +202,7 @@ class PersonJsonNormalizer implements DenormalizerAwareInterface, NormalizerAwar
|
||||
'phonenumber' => $this->normalizer->normalize($person->getPhonenumber(), $format, $context),
|
||||
'mobilenumber' => $this->normalizer->normalize($person->getMobilenumber(), $format, $context),
|
||||
'email' => $person->getEmail(),
|
||||
'gender' => $person->getGender(),
|
||||
'gender' => $this->normalizer->normalize($person->getGender(), $format, $context),
|
||||
'civility' => $this->normalizer->normalize($person->getCivility(), $format, $context),
|
||||
];
|
||||
|
||||
|
Reference in New Issue
Block a user