]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/ApiBundle/Controller/WallabagRestController.php
fix cs and phpdoc
[github/wallabag/wallabag.git] / src / Wallabag / ApiBundle / Controller / WallabagRestController.php
index 96f7580744a4dcefc53c6c01da010b4457e9d27f..0c709ca099dfb964715338ce96ab413ef4310900 100644 (file)
@@ -6,13 +6,14 @@ use FOS\RestBundle\Controller\FOSRestController;
 use Hateoas\Configuration\Route as HateoasRoute;
 use Hateoas\Representation\Factory\PagerfantaFactory;
 use Nelmio\ApiDocBundle\Annotation\ApiDoc;
+use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpFoundation\JsonResponse;
 use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
 use Symfony\Component\Security\Core\Exception\AccessDeniedException;
 use Wallabag\CoreBundle\Entity\Entry;
 use Wallabag\CoreBundle\Entity\Tag;
-use FOS\RestBundle\Controller\Annotations\Route;
+use Wallabag\AnnotationBundle\Entity\Annotation;
 
 class WallabagRestController extends FOSRestController
 {
@@ -518,6 +519,103 @@ class WallabagRestController extends FOSRestController
         return (new JsonResponse())->setJson($json);
     }
 
+    /**
+     * Retrieve annotations for an entry.
+     *
+     * @ApiDoc(
+     *      requirements={
+     *          {"name"="entry", "dataType"="integer", "requirement"="\w+", "description"="The entry ID"}
+     *      }
+     * )
+     *
+     * @param Entry $entry
+     *
+     * @return JsonResponse
+     */
+    public function getAnnotationsAction(Entry $entry)
+    {
+        $this->validateAuthentication();
+
+        return $this->forward('WallabagApiBundle:WallabagRest:getAnnotations', [
+            'entry' => $entry,
+        ]);
+    }
+
+    /**
+     * Creates a new annotation.
+     *
+     * @param Request $request
+     * @param Entry   $entry
+     *
+     * @return JsonResponse
+     * @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"=""},
+     *      }
+     * )
+     */
+    public function postAnnotationAction(Request $request, Entry $entry)
+    {
+        $this->validateAuthentication();
+
+        return $this->forward('WallabagApiBundle:WallabagRest:postAnnotation', [
+                'request' => $request,
+                'entry' => $entry,
+            ]);
+    }
+
+    /**
+     * Updates an annotation.
+     *
+     * @ApiDoc(
+     *      requirements={
+     *          {"name"="annotation", "dataType"="string", "requirement"="\w+", "description"="The annotation ID"}
+     *      }
+     * )
+     *
+     * @ParamConverter("annotation", class="WallabagAnnotationBundle:Annotation")
+     *
+     * @param Annotation $annotation
+     * @param Request    $request
+     *
+     * @return JsonResponse
+     */
+    public function putAnnotationAction(Annotation $annotation, Request $request)
+    {
+        $this->validateAuthentication();
+
+        return $this->forward('WallabagApiBundle:WallabagRest:putAnnotation', [
+                'annotation' => $annotation,
+                'request' => $request,
+            ]);
+    }
+
+    /**
+     * Removes an annotation.
+     *
+     * @ApiDoc(
+     *      requirements={
+     *          {"name"="annotation", "dataType"="string", "requirement"="\w+", "description"="The annotation ID"}
+     *      }
+     * )
+     *
+     * @ParamConverter("annotation", class="WallabagAnnotationBundle:Annotation")
+     *
+     * @param Annotation $annotation
+     *
+     * @return JsonResponse
+     */
+    public function deleteAnnotationAction(Annotation $annotation)
+    {
+        $this->validateAuthentication();
+
+        return $this->forward('WallabagApiBundle:WallabagRest:deleteAnnotation', [
+                'annotation' => $annotation,
+            ]);
+    }
+
     /**
      * Retrieve version number.
      *