From 351eb8d97ea1520f87ae762faf297083a716c945 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Fri, 18 Mar 2016 16:41:23 +0100 Subject: bring annotations to API --- .../Controller/WallabagAnnotationController.php | 28 +++++----------------- 1 file changed, 6 insertions(+), 22 deletions(-) (limited to 'src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php') diff --git a/src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php b/src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php index ad083e31..80ac0035 100644 --- a/src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php +++ b/src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php @@ -15,11 +15,9 @@ class WallabagAnnotationController extends FOSRestController /** * Retrieve annotations for an entry. * - * @ApiDoc( - * requirements={ - * {"name"="entry", "dataType"="integer", "requirement"="\w+", "description"="The entry ID"} - * } - * ) + * @param Entry $entry + * + * @see Wallabag\ApiBundle\Controller\WallabagRestController * * @return Response */ @@ -42,13 +40,7 @@ class WallabagAnnotationController extends FOSRestController * * @param Entry $entry * - * @ApiDoc( - * requirements={ - * {"name"="ranges", "dataType"="array", "requirement"="\w+", "description"="The range array for the annotation"}, - * {"name"="quote", "dataType"="string", "required"=false, "description"="Optional, quote for the annotation"}, - * {"name"="text", "dataType"="string", "required"=true, "description"=""}, - * } - * ) + * @see Wallabag\ApiBundle\Controller\WallabagRestController * * @return Response */ @@ -81,11 +73,7 @@ class WallabagAnnotationController extends FOSRestController /** * Updates an annotation. * - * @ApiDoc( - * requirements={ - * {"name"="annotation", "dataType"="string", "requirement"="\w+", "description"="The annotation ID"} - * } - * ) + * @see Wallabag\ApiBundle\Controller\WallabagRestController * * @ParamConverter("annotation", class="WallabagAnnotationBundle:Annotation") * @@ -110,11 +98,7 @@ class WallabagAnnotationController extends FOSRestController /** * Removes an annotation. * - * @ApiDoc( - * requirements={ - * {"name"="annotation", "dataType"="string", "requirement"="\w+", "description"="The annotation ID"} - * } - * ) + * @see Wallabag\ApiBundle\Controller\WallabagRestController * * @ParamConverter("annotation", class="WallabagAnnotationBundle:Annotation") * -- cgit v1.2.3 From c7935f32d2cd7fd29dbc7b07c8f206f6e8b64fb4 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Fri, 18 Mar 2016 22:23:49 +0100 Subject: cs --- .../AnnotationBundle/Controller/WallabagAnnotationController.php | 1 - 1 file changed, 1 deletion(-) (limited to 'src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php') diff --git a/src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php b/src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php index 80ac0035..4143c1b6 100644 --- a/src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php +++ b/src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php @@ -3,7 +3,6 @@ namespace Wallabag\AnnotationBundle\Controller; use FOS\RestBundle\Controller\FOSRestController; -use Nelmio\ApiDocBundle\Annotation\ApiDoc; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; -- cgit v1.2.3 From 1eea248bb0ebf49772878557211817905a4d6952 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 5 Oct 2016 19:16:57 +0200 Subject: move code --- .../Controller/WallabagAnnotationController.php | 43 +++++++++------------- 1 file changed, 17 insertions(+), 26 deletions(-) (limited to 'src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php') diff --git a/src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php b/src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php index 4143c1b6..b04c0bc2 100644 --- a/src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php +++ b/src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php @@ -3,6 +3,7 @@ namespace Wallabag\AnnotationBundle\Controller; use FOS\RestBundle\Controller\FOSRestController; +use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; @@ -18,30 +19,30 @@ class WallabagAnnotationController extends FOSRestController * * @see Wallabag\ApiBundle\Controller\WallabagRestController * - * @return Response + * @return JsonResponse */ public function getAnnotationsAction(Entry $entry) { $annotationRows = $this - ->getDoctrine() - ->getRepository('WallabagAnnotationBundle:Annotation') - ->findAnnotationsByPageId($entry->getId(), $this->getUser()->getId()); + ->getDoctrine() + ->getRepository('WallabagAnnotationBundle:Annotation') + ->findAnnotationsByPageId($entry->getId(), $this->getUser()->getId()); $total = count($annotationRows); - $annotations = ['total' => $total, 'rows' => $annotationRows]; + $annotations = array('total' => $total, 'rows' => $annotationRows); $json = $this->get('serializer')->serialize($annotations, 'json'); - return $this->renderJsonResponse($json); + return (new JsonResponse())->setJson($json); } /** * Creates a new annotation. * + * @param Request $request * @param Entry $entry - * + * @return JsonResponse * @see Wallabag\ApiBundle\Controller\WallabagRestController * - * @return Response */ public function postAnnotationAction(Request $request, Entry $entry) { @@ -66,7 +67,7 @@ class WallabagAnnotationController extends FOSRestController $json = $this->get('serializer')->serialize($annotation, 'json'); - return $this->renderJsonResponse($json); + return (new JsonResponse())->setJson($json); } /** @@ -76,7 +77,9 @@ class WallabagAnnotationController extends FOSRestController * * @ParamConverter("annotation", class="WallabagAnnotationBundle:Annotation") * - * @return Response + * @param Annotation $annotation + * @param Request $request + * @return JsonResponse */ public function putAnnotationAction(Annotation $annotation, Request $request) { @@ -91,7 +94,7 @@ class WallabagAnnotationController extends FOSRestController $json = $this->get('serializer')->serialize($annotation, 'json'); - return $this->renderJsonResponse($json); + return (new JsonResponse())->setJson($json); } /** @@ -101,7 +104,8 @@ class WallabagAnnotationController extends FOSRestController * * @ParamConverter("annotation", class="WallabagAnnotationBundle:Annotation") * - * @return Response + * @param Annotation $annotation + * @return JsonResponse */ public function deleteAnnotationAction(Annotation $annotation) { @@ -111,19 +115,6 @@ class WallabagAnnotationController extends FOSRestController $json = $this->get('serializer')->serialize($annotation, 'json'); - return $this->renderJsonResponse($json); - } - - /** - * Send a JSON Response. - * We don't use the Symfony JsonRespone, because it takes an array as parameter instead of a JSON string. - * - * @param string $json - * - * @return Response - */ - private function renderJsonResponse($json, $code = 200) - { - return new Response($json, $code, ['application/json']); + return (new JsonResponse())->setJson($json); } } -- cgit v1.2.3 From b1e92f8c14d3d506f2bfab628ba8ed95de0e8b51 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Thu, 6 Oct 2016 11:40:14 +0200 Subject: cs --- .../Controller/WallabagAnnotationController.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php') diff --git a/src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php b/src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php index b04c0bc2..519fd2f5 100644 --- a/src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php +++ b/src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php @@ -5,7 +5,6 @@ namespace Wallabag\AnnotationBundle\Controller; use FOS\RestBundle\Controller\FOSRestController; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; use Wallabag\AnnotationBundle\Entity\Annotation; use Wallabag\CoreBundle\Entity\Entry; @@ -39,10 +38,11 @@ class WallabagAnnotationController extends FOSRestController * Creates a new annotation. * * @param Request $request - * @param Entry $entry + * @param Entry $entry + * * @return JsonResponse - * @see Wallabag\ApiBundle\Controller\WallabagRestController * + * @see Wallabag\ApiBundle\Controller\WallabagRestController */ public function postAnnotationAction(Request $request, Entry $entry) { @@ -78,7 +78,8 @@ class WallabagAnnotationController extends FOSRestController * @ParamConverter("annotation", class="WallabagAnnotationBundle:Annotation") * * @param Annotation $annotation - * @param Request $request + * @param Request $request + * * @return JsonResponse */ public function putAnnotationAction(Annotation $annotation, Request $request) @@ -105,6 +106,7 @@ class WallabagAnnotationController extends FOSRestController * @ParamConverter("annotation", class="WallabagAnnotationBundle:Annotation") * * @param Annotation $annotation + * * @return JsonResponse */ public function deleteAnnotationAction(Annotation $annotation) -- cgit v1.2.3 From 0c271b9eb0813162b82c6b3bc38604716398ddd1 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Sun, 9 Oct 2016 14:01:28 +0200 Subject: fix cs and phpdoc --- .../AnnotationBundle/Controller/WallabagAnnotationController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php') diff --git a/src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php b/src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php index 519fd2f5..c13a034f 100644 --- a/src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php +++ b/src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php @@ -27,7 +27,7 @@ class WallabagAnnotationController extends FOSRestController ->getRepository('WallabagAnnotationBundle:Annotation') ->findAnnotationsByPageId($entry->getId(), $this->getUser()->getId()); $total = count($annotationRows); - $annotations = array('total' => $total, 'rows' => $annotationRows); + $annotations = ['total' => $total, 'rows' => $annotationRows]; $json = $this->get('serializer')->serialize($annotations, 'json'); -- cgit v1.2.3