From 1b567327b7a2f1aa6a918e744b10c63186b0d845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 30 Mar 2022 12:37:18 +0200 Subject: [PATCH] fix normalisation for phonenumber in person entity --- .../ChillMainBundle/CRUD/Controller/ApiController.php | 6 +++--- .../Serializer/Normalizer/PersonJsonNormalizer.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php b/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php index cfbe811fa..10c530794 100644 --- a/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php +++ b/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php @@ -33,11 +33,11 @@ class ApiController extends AbstractCRUDController * Base method for handling api action. * * @param mixed $id - * @param mixed $_format + * @param string $_format * * @return void */ - public function entityApi(Request $request, $id, $_format): Response + public function entityApi(Request $request, $id, ?string $_format = 'json'): Response { switch ($request->getMethod()) { case Request::METHOD_GET: @@ -49,7 +49,7 @@ class ApiController extends AbstractCRUDController return $this->entityPut('_entity', $request, $id, $_format); case Request::METHOD_POST: - return $this->entityPostAction('_entity', $request, $id); + return $this->entityPostAction('_entity', $request, $id, $_format); case Request::METHOD_DELETE: return $this->entityDelete('_entity', $request, $id, $_format); diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php index ae95c9321..41c06e9ec 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php @@ -208,8 +208,8 @@ class PersonJsonNormalizer implements DenormalizerAwareInterface, NormalizerAwar 'birthdate' => $this->normalizer->normalize($person->getBirthdate(), $format, $context), 'deathdate' => $this->normalizer->normalize($person->getDeathdate(), $format, $context), 'age' => $this->normalizer->normalize($person->getAge(), $format, $context), - 'phonenumber' => $this->normalizer->normalize($person->getPhonenumber()), - 'mobilenumber' => $this->normalizer->normalize($person->getMobilenumber()), + 'phonenumber' => $this->normalizer->normalize($person->getPhonenumber(), $format, $context), + 'mobilenumber' => $this->normalizer->normalize($person->getMobilenumber(), $format, $context), 'email' => $person->getEmail(), 'gender' => $person->getGender(), ];