]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
improve hateoas implementation
authorNicolas Lœuillet <nicolas@loeuillet.org>
Fri, 20 Feb 2015 13:18:01 +0000 (14:18 +0100)
committerNicolas Lœuillet <nicolas@loeuillet.org>
Fri, 6 Mar 2015 19:50:30 +0000 (20:50 +0100)
src/Wallabag/CoreBundle/Controller/WallabagRestController.php

index d48c7bbb2f18389cb0a5b4deba725542db3f9717..b9f7efea034193111cd77e897a005aedc9ef1e34 100644 (file)
@@ -10,7 +10,6 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
 use Wallabag\CoreBundle\Entity\Entry;
 use Wallabag\CoreBundle\Entity\Tag;
 use Wallabag\CoreBundle\Service\Extractor;
-use Hateoas\HateoasBuilder;
 
 class WallabagRestController extends Controller
 {
@@ -74,8 +73,7 @@ class WallabagRestController extends Controller
             throw $this->createNotFoundException();
         }
 
-        $hateoas = HateoasBuilder::create()->build();
-        $json = $hateoas->serialize($entries, 'json');
+        $json = $this->get('serializer')->serialize($entries, 'json');
 
         return new Response($json, 200, array('application/json'));
     }
@@ -92,8 +90,7 @@ class WallabagRestController extends Controller
      */
     public function getEntryAction(Entry $entry)
     {
-        $hateoas = HateoasBuilder::create()->build();
-        $json = $hateoas->serialize($entry, 'json');
+        $json = $this->get('serializer')->serialize($entry, 'json');
 
         return new Response($json, 200, array('application/json'));
     }
@@ -124,7 +121,9 @@ class WallabagRestController extends Controller
         $em->persist($entry);
         $em->flush();
 
-        return $entry;
+        $json = $this->get('serializer')->serialize($entry, 'json');
+
+        return new Response($json, 200, array('application/json'));
     }
 
     /**