From 0f00688096645606c7806a619ca27e6f30ce820c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 20 Feb 2015 11:45:38 +0100 Subject: first draft of hypermedia implementation --- src/Wallabag/CoreBundle/Controller/WallabagRestController.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/Wallabag/CoreBundle/Controller') diff --git a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php index e9cd8c93..cadd7e75 100644 --- a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php +++ b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php @@ -5,10 +5,12 @@ namespace Wallabag\CoreBundle\Controller; use Nelmio\ApiDocBundle\Annotation\ApiDoc; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; 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 { @@ -72,6 +74,9 @@ class WallabagRestController extends Controller throw $this->createNotFoundException(); } + $hateoas = HateoasBuilder::create()->build(); + $json = $hateoas->serialize($entries, 'json'); + return $entries; } @@ -87,7 +92,10 @@ class WallabagRestController extends Controller */ public function getEntryAction(Entry $entry) { - return $entry; + $hateoas = HateoasBuilder::create()->build(); + $json = $hateoas->serialize($entry, 'json'); + + return new Response($json, 200, array('application/json')); } /** -- cgit v1.2.3