X-Git-Url: https://git.piment-noir.org/?p=Project_proches_de_moi-server.git;a=blobdiff_plain;f=src%2FController%2FPersonController.php;h=b452c6360093b108b2f42b373311d7bf5cd42381;hp=785377114530cfea5c1a353db4b3fc156ef18053;hb=4c4feb3e3193703f6cfa44ca711092a8acb38329;hpb=eaccb96ea30d1e2f0789ab34d87deb8049df62b9 diff --git a/src/Controller/PersonController.php b/src/Controller/PersonController.php index 7853771..b452c63 100644 --- a/src/Controller/PersonController.php +++ b/src/Controller/PersonController.php @@ -82,6 +82,26 @@ class PersonController extends Controller } + /** + * @Rest\Get("/api/person/{id}/localisations") + */ + public function getLocalisationActions(Request $request) + { + $em = $this->getDoctrine()->getManager(); + $localisations = $em->getRepository('App:Localisation')->findBy(['person_id' => $request->get('id')]); + + if (empty($localisations)) { + return View::create(['message' => 'Person localisation not found'], Response::HTTP_NOT_FOUND); + } + + $view = View::create($localisation); + $view->setFormat('json'); + + $viewHandler = $this->get('fos_rest.view_handler'); + return $viewHandler->handle($view); + + } + /** * @Rest\Post("/api/person/{id}/localisation") * @Rest\View(StatusCode = Response::HTTP_CREATED)