From: Jérôme Benoit Date: Wed, 27 Jun 2018 21:53:19 +0000 (+0200) Subject: Better error handling. X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=d26857346e3472ad79b8b25f65cfd61d6cb1a5cb;p=Project_proches_de_moi-server.git Better error handling. Signed-off-by: Jérôme Benoit --- diff --git a/config/config.yaml b/config/config.yaml index 6aab19c..1bb645b 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -14,6 +14,8 @@ fos_rest: format_listener: rules: - { path: '^/api', priorities: ['json'], fallback_format: 'json' } + body_listener: + enabled: true versioning: enabled: true resolvers: diff --git a/src/Controller/PersonController.php b/src/Controller/PersonController.php index 5dd8f23..18f4a3e 100644 --- a/src/Controller/PersonController.php +++ b/src/Controller/PersonController.php @@ -61,7 +61,7 @@ class PersonController extends Controller $person = $em->getRepository('App:Person')->find($request->get('id')); if (empty($person)) { - return new JsonResponse(['message' => 'Person not found'], Response::HTTP_NOT_FOUND); + return View::create(['message' => 'Person not found'], Response::HTTP_NOT_FOUND); } $person->setFirstName($request->get('firstname')); @@ -114,7 +114,7 @@ class PersonController extends Controller $person = $em->getRepository('App:Person')->find($request->get('id')); if (empty($person)) { - return new JsonResponse(['message' => 'Person not found'], Response::HTTP_NOT_FOUND); + return View::create(['message' => 'Person not found'], Response::HTTP_NOT_FOUND); } $view = View::create($person); @@ -137,7 +137,7 @@ class PersonController extends Controller $person = $em->getRepository('App:Person')->find($request->get('email')); if (empty($person)) { - return new JsonResponse(['message' => 'Person not found'], Response::HTTP_NOT_FOUND); + return View::create(['message' => 'Person not found'], Response::HTTP_NOT_FOUND); } $view = View::create($person); @@ -160,7 +160,7 @@ class PersonController extends Controller $person = $em->getRepository('App:Person')->find($request->get('id')); if (empty($person)) { - return new JsonResponse(['message' => 'Person not found'], Response::HTTP_NOT_FOUND); + return View::create(['message' => 'Person not found'], Response::HTTP_NOT_FOUND); } $view = View::create($person->getFriends()); @@ -183,7 +183,7 @@ class PersonController extends Controller $person = $em->getRepository('App:Person')->find($request->get('email')); if (empty($person)) { - return new JsonResponse(['message' => 'Person not found'], Response::HTTP_NOT_FOUND); + return View::create(['message' => 'Person not found'], Response::HTTP_NOT_FOUND); } $view = View::create($person->getFriends());