]> git.immae.eu Git - github/wallabag/wallabag.git/blob - src/Wallabag/ApiBundle/Controller/AnnotationRestController.php
Add client_credentials as grant_type
[github/wallabag/wallabag.git] / src / Wallabag / ApiBundle / Controller / AnnotationRestController.php
1 <?php
2
3 namespace Wallabag\ApiBundle\Controller;
4
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;
12
13 class AnnotationRestController extends WallabagRestController
14 {
15 /**
16 * Retrieve annotations for an entry.
17 *
18 * @ApiDoc(
19 * requirements={
20 * {"name"="entry", "dataType"="integer", "requirement"="\w+", "description"="The entry ID"}
21 * }
22 * )
23 *
24 * @param Entry $entry
25 * @Security("has_role('ROLE_READ')")
26 * @return JsonResponse
27 */
28 public function getAnnotationsAction(Entry $entry)
29 {
30 $this->validateAuthentication();
31
32 return $this->forward('WallabagAnnotationBundle:WallabagAnnotation:getAnnotations', [
33 'entry' => $entry,
34 ]);
35 }
36
37 /**
38 * Creates a new annotation.
39 *
40 * @ApiDoc(
41 * requirements={
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"=""},
45 * }
46 * )
47 *
48 * @param Request $request
49 * @param Entry $entry
50 * @Security("has_role('ROLE_WRITE')")
51 * @return JsonResponse
52 */
53 public function postAnnotationAction(Request $request, Entry $entry)
54 {
55 $this->validateAuthentication();
56
57 return $this->forward('WallabagAnnotationBundle:WallabagAnnotation:postAnnotation', [
58 'request' => $request,
59 'entry' => $entry,
60 ]);
61 }
62
63 /**
64 * Updates an annotation.
65 *
66 * @ApiDoc(
67 * requirements={
68 * {"name"="annotation", "dataType"="string", "requirement"="\w+", "description"="The annotation ID"}
69 * }
70 * )
71 *
72 * @ParamConverter("annotation", class="WallabagAnnotationBundle:Annotation")
73 *
74 * @param Annotation $annotation
75 * @param Request $request
76 * @Security("has_role('ROLE_WRITE')")
77 * @return JsonResponse
78 */
79 public function putAnnotationAction(Annotation $annotation, Request $request)
80 {
81 $this->validateAuthentication();
82
83 return $this->forward('WallabagAnnotationBundle:WallabagAnnotation:putAnnotation', [
84 'annotation' => $annotation,
85 'request' => $request,
86 ]);
87 }
88
89 /**
90 * Removes an annotation.
91 *
92 * @ApiDoc(
93 * requirements={
94 * {"name"="annotation", "dataType"="string", "requirement"="\w+", "description"="The annotation ID"}
95 * }
96 * )
97 *
98 * @ParamConverter("annotation", class="WallabagAnnotationBundle:Annotation")
99 *
100 * @param Annotation $annotation
101 * @Security("has_role('ROLE_WRITE')")
102 * @return JsonResponse
103 */
104 public function deleteAnnotationAction(Annotation $annotation)
105 {
106 $this->validateAuthentication();
107
108 return $this->forward('WallabagAnnotationBundle:WallabagAnnotation:deleteAnnotation', [
109 'annotation' => $annotation,
110 ]);
111 }
112 }