diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php b/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php index 23f6ec95d..3a3613c8b 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php @@ -78,4 +78,35 @@ class PersonApiController extends ApiController new Role(PersonVoter::CREATE)); $person->setCenter($centers[0]); */ } + + /** + * @Route("/api/1.0/person/config/alt_names.{_format}", + * name="chill_person_config_alt_names", + * requirements={ + * "_format": "json" + * } + * ) + */ + public function configAltNames(Request $request, string $_format): Response + { + + //TODO get alt_name config from chill person + $configAltNames = ["key" => "jeune_fille", "labels" => ["fr" => "Nom de naisssance" ]]; //TODO fake data + + return $this->json($configAltNames, Response::HTTP_OK, [], ['groups' => ['read']]); + } + + public function getValidationGroups(string $action, Request $request, string $_format, $entity): ?array + { + if ($action === '_entity'){ + if ($request->getMethod() === Request::METHOD_POST){ + return ["creation"]; + } + if (($request->getMethod() === Request::METHOD_PATCH) || ($request->getMethod() === Request::METHOD_PUT)){ + return ["general"]; + } + }; + return parent::getValidationGroups($action, $request, $_format, $entity); + } + }