Use view handler where appropriate.
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 28 Jun 2018 07:27:00 +0000 (09:27 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 28 Jun 2018 07:27:00 +0000 (09:27 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
src/Controller/PersonController.php
src/Entity/Person.php

index 18f4a3ed7777e36c454a9b8d370058e1f4554c7b..785377114530cfea5c1a353db4b3fc156ef18053 100644 (file)
@@ -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);
  }
 }
index 701b9e63cc6a550591be4a919a690e2b3193eb2a..d1c7886bf2dfab2cda322d0a2d35322077b85465 100644 (file)
@@ -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);