From: Jérôme Benoit Date: Thu, 28 Jun 2018 07:27:00 +0000 (+0200) Subject: Use view handler where appropriate. X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=d68c207331ee5c52769c538984e69ca7bbe5e902;p=Project_proches_de_moi-server.git Use view handler where appropriate. Signed-off-by: Jérôme Benoit --- diff --git a/src/Controller/PersonController.php b/src/Controller/PersonController.php index 18f4a3e..7853771 100644 --- a/src/Controller/PersonController.php +++ b/src/Controller/PersonController.php @@ -120,7 +120,8 @@ class PersonController extends Controller $view = View::create($person); $view->setFormat('json'); - return $view; + $viewHandler = $this->get('fos_rest.view_handler'); + return $viewHandler->handle($view); } /** @@ -143,7 +144,8 @@ class PersonController extends Controller $view = View::create($person); $view->setFormat('json'); - return $view; + $viewHandler = $this->get('fos_rest.view_handler'); + return $viewHandler->handle($view); } /** @@ -166,7 +168,8 @@ class PersonController extends Controller $view = View::create($person->getFriends()); $view->setFormat('json'); - return $view; + $viewHandler = $this->get('fos_rest.view_handler'); + return $viewHandler->handle($view); } /** @@ -189,6 +192,7 @@ class PersonController extends Controller $view = View::create($person->getFriends()); $view->setFormat('json'); - return $view; + $viewHandler = $this->get('fos_rest.view_handler'); + return $viewHandler->handle($view); } } diff --git a/src/Entity/Person.php b/src/Entity/Person.php index 701b9e6..d1c7886 100644 --- a/src/Entity/Person.php +++ b/src/Entity/Person.php @@ -154,7 +154,7 @@ class Person $this->friends_with_me->add($friendship); } - public function addFriend(User $friend) + public function addFriend(Person $friend) { $fs = new Friendship(); $fs->setPerson($this);