mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
person: add api endpoint for altname + implement getValidationGroups
This commit is contained in:
parent
438cb7317a
commit
3d3ce7814b
@ -78,4 +78,35 @@ class PersonApiController extends ApiController
|
|||||||
new Role(PersonVoter::CREATE));
|
new Role(PersonVoter::CREATE));
|
||||||
$person->setCenter($centers[0]); */
|
$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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user