X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2FController%2FPersonController.php;h=f2e73c132454b5e4d3bf98fc763ab7f121b7fe0f;hb=1de9ba73a6b77b98e94f797623b80b9d993cf01e;hp=785377114530cfea5c1a353db4b3fc156ef18053;hpb=d68c207331ee5c52769c538984e69ca7bbe5e902;p=Project_proches_de_moi-server.git diff --git a/src/Controller/PersonController.php b/src/Controller/PersonController.php index 7853771..f2e73c1 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 getLocalisationsAction(Request $request) + { + $em = $this->getDoctrine()->getManager(); + $localisations = $em->getRepository('App:Localisation')->findBy(['person' => $request->get('id')]); + + if (empty($localisations)) { + return View::create(['message' => 'Person localisations not found'], Response::HTTP_NOT_FOUND); + } + + $view = View::create($localisations); + $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)