mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
person: fix adding civility to a person with OnTheFly form
This commit is contained in:
@@ -12,7 +12,9 @@ declare(strict_types=1);
|
||||
namespace Chill\PersonBundle\Serializer\Normalizer;
|
||||
|
||||
use Chill\MainBundle\Entity\Center;
|
||||
use Chill\MainBundle\Entity\Civility;
|
||||
use Chill\MainBundle\Phonenumber\PhoneNumberHelperInterface;
|
||||
use Chill\MainBundle\Repository\CivilityRepository;
|
||||
use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface;
|
||||
use Chill\MainBundle\Templating\Entity\ChillEntityRenderExtension;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
@@ -54,6 +56,8 @@ class PersonJsonNormalizer implements DenormalizerAwareInterface, NormalizerAwar
|
||||
|
||||
private PersonRepository $repository;
|
||||
|
||||
private CivilityRepository $civilityRepository;
|
||||
|
||||
private ResidentialAddressRepository $residentialAddressRepository;
|
||||
|
||||
public function __construct(
|
||||
@@ -61,12 +65,14 @@ class PersonJsonNormalizer implements DenormalizerAwareInterface, NormalizerAwar
|
||||
PersonRepository $repository,
|
||||
CenterResolverManagerInterface $centerResolverManager,
|
||||
ResidentialAddressRepository $residentialAddressRepository,
|
||||
CivilityRepository $civilityRepository,
|
||||
PhoneNumberHelperInterface $phoneNumberHelper /* TODO maybe not necessayr any more */
|
||||
) {
|
||||
$this->render = $render;
|
||||
$this->repository = $repository;
|
||||
$this->centerResolverManager = $centerResolverManager;
|
||||
$this->residentialAddressRepository = $residentialAddressRepository;
|
||||
$this->civilityRepository = $civilityRepository;
|
||||
$this->phoneNumberHelper = $phoneNumberHelper;
|
||||
}
|
||||
|
||||
@@ -101,6 +107,7 @@ class PersonJsonNormalizer implements DenormalizerAwareInterface, NormalizerAwar
|
||||
'center',
|
||||
'altNames',
|
||||
'email',
|
||||
'civility'
|
||||
];
|
||||
|
||||
$fields = array_filter(
|
||||
@@ -176,6 +183,14 @@ class PersonJsonNormalizer implements DenormalizerAwareInterface, NormalizerAwar
|
||||
case 'email':
|
||||
$person->setEmail($data[$item]);
|
||||
|
||||
break;
|
||||
|
||||
case 'civility':
|
||||
//$civility = $this->denormalizer->denormalize($data[$item], Civility::class, $format, $context); // this seems the right way to do it, but this does not render a Civility object.
|
||||
$civility = $this->civilityRepository->findOneBy(['id' => $data[$item]['id']]);
|
||||
|
||||
$person->setCivility($civility);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user