Add ressources to get all users.
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 28 Jun 2018 10:07:39 +0000 (12:07 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 28 Jun 2018 10:07:39 +0000 (12:07 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
src/Controller/PersonController.php

index 0fb898527414e14ff7c940e3744cd8ea7f2c1edb..102b6980245824c6ca33201fe66ae29d641a3573 100644 (file)
@@ -200,6 +200,31 @@ class PersonController extends Controller
         return $viewHandler->handle($view);
   }
 
+  /**
+  * @Rest\Get(
+  *     path = "/api/persons",
+  *     name = "show_persons"
+  * )
+  * @Rest\View()
+  */
+ public function showPersons(Request $request)
+ {
+       $em = $this->getDoctrine()->getManager();
+       $persons = $em->getRepository('App:Person')->findAll();
+
+       $viewHandler = $this->get('fos_rest.view_handler');
+
+       if (empty($persons)) {
+           return $this->PersonNotFound($viewHandler);
+       }
+
+       // $view = View::create($persons);
+       // $view->setFormat('json');
+       //
+       // return $viewHandler->handle($view);
+       return $persons;
+ }
+
   /**
   * @Rest\Get(
   *     path = "/api/person/{email}/friends",