3 namespace Wallabag\ApiBundle\Controller
;
5 use Nelmio\ApiDocBundle\Annotation\ApiDoc
;
6 use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter
;
7 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security
;
8 use Symfony\Component\HttpFoundation\Request
;
9 use Symfony\Component\HttpFoundation\JsonResponse
;
10 use Wallabag\CoreBundle\Entity\Entry
;
11 use Wallabag\AnnotationBundle\Entity\Annotation
;
13 class AnnotationRestController
extends WallabagRestController
16 * Retrieve annotations for an entry.
20 * {"name"="entry", "dataType"="integer", "requirement"="\w+", "description"="The entry ID"}
25 * @Security("has_role('ROLE_READ')")
26 * @return JsonResponse
28 public function getAnnotationsAction(Entry
$entry)
30 $this->validateAuthentication();
32 return $this->forward('WallabagAnnotationBundle:WallabagAnnotation:getAnnotations', [
38 * Creates a new annotation.
42 * {"name"="ranges", "dataType"="array", "requirement"="\w+", "description"="The range array for the annotation"},
43 * {"name"="quote", "dataType"="string", "required"=false, "description"="Optional, quote for the annotation"},
44 * {"name"="text", "dataType"="string", "required"=true, "description"=""},
48 * @param Request $request
50 * @Security("has_role('ROLE_WRITE')")
51 * @return JsonResponse
53 public function postAnnotationAction(Request
$request, Entry
$entry)
55 $this->validateAuthentication();
57 return $this->forward('WallabagAnnotationBundle:WallabagAnnotation:postAnnotation', [
58 'request' => $request,
64 * Updates an annotation.
68 * {"name"="annotation", "dataType"="string", "requirement"="\w+", "description"="The annotation ID"}
72 * @ParamConverter("annotation", class="WallabagAnnotationBundle:Annotation")
74 * @param Annotation $annotation
75 * @param Request $request
76 * @Security("has_role('ROLE_WRITE')")
77 * @return JsonResponse
79 public function putAnnotationAction(Annotation
$annotation, Request
$request)
81 $this->validateAuthentication();
83 return $this->forward('WallabagAnnotationBundle:WallabagAnnotation:putAnnotation', [
84 'annotation' => $annotation,
85 'request' => $request,
90 * Removes an annotation.
94 * {"name"="annotation", "dataType"="string", "requirement"="\w+", "description"="The annotation ID"}
98 * @ParamConverter("annotation", class="WallabagAnnotationBundle:Annotation")
100 * @param Annotation $annotation
101 * @Security("has_role('ROLE_WRITE')")
102 * @return JsonResponse
104 public function deleteAnnotationAction(Annotation
$annotation)
106 $this->validateAuthentication();
108 return $this->forward('WallabagAnnotationBundle:WallabagAnnotation:deleteAnnotation', [
109 'annotation' => $annotation,