]> git.immae.eu Git - github/wallabag/wallabag.git/blame - src/Wallabag/ApiBundle/Controller/AnnotationRestController.php
Add a real configuration for CS-Fixer
[github/wallabag/wallabag.git] / src / Wallabag / ApiBundle / Controller / AnnotationRestController.php
CommitLineData
864c1dd2
JB
1<?php
2
3namespace Wallabag\ApiBundle\Controller;
4
5use Nelmio\ApiDocBundle\Annotation\ApiDoc;
6use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
864c1dd2 7use Symfony\Component\HttpFoundation\JsonResponse;
f808b016 8use Symfony\Component\HttpFoundation\Request;
864c1dd2 9use Wallabag\AnnotationBundle\Entity\Annotation;
f808b016 10use Wallabag\CoreBundle\Entity\Entry;
864c1dd2
JB
11
12class AnnotationRestController extends WallabagRestController
13{
14 /**
15 * Retrieve annotations for an entry.
16 *
17 * @ApiDoc(
18 * requirements={
19 * {"name"="entry", "dataType"="integer", "requirement"="\w+", "description"="The entry ID"}
20 * }
21 * )
22 *
23 * @param Entry $entry
24 *
25 * @return JsonResponse
26 */
27 public function getAnnotationsAction(Entry $entry)
28 {
29 $this->validateAuthentication();
30
31 return $this->forward('WallabagAnnotationBundle:WallabagAnnotation:getAnnotations', [
32 'entry' => $entry,
33 ]);
34 }
35
36 /**
37 * Creates a new annotation.
38 *
39 * @ApiDoc(
40 * requirements={
41 * {"name"="ranges", "dataType"="array", "requirement"="\w+", "description"="The range array for the annotation"},
42 * {"name"="quote", "dataType"="string", "required"=false, "description"="Optional, quote for the annotation"},
43 * {"name"="text", "dataType"="string", "required"=true, "description"=""},
44 * }
45 * )
46 *
47 * @param Request $request
48 * @param Entry $entry
49 *
50 * @return JsonResponse
51 */
52 public function postAnnotationAction(Request $request, Entry $entry)
53 {
54 $this->validateAuthentication();
55
56 return $this->forward('WallabagAnnotationBundle:WallabagAnnotation:postAnnotation', [
57 'request' => $request,
58 'entry' => $entry,
59 ]);
60 }
61
62 /**
63 * Updates an annotation.
64 *
65 * @ApiDoc(
66 * requirements={
67 * {"name"="annotation", "dataType"="string", "requirement"="\w+", "description"="The annotation ID"}
68 * }
69 * )
70 *
71 * @ParamConverter("annotation", class="WallabagAnnotationBundle:Annotation")
72 *
73 * @param Annotation $annotation
74 * @param Request $request
75 *
76 * @return JsonResponse
77 */
78 public function putAnnotationAction(Annotation $annotation, Request $request)
79 {
80 $this->validateAuthentication();
81
82 return $this->forward('WallabagAnnotationBundle:WallabagAnnotation:putAnnotation', [
83 'annotation' => $annotation,
84 'request' => $request,
85 ]);
86 }
87
88 /**
89 * Removes an annotation.
90 *
91 * @ApiDoc(
92 * requirements={
93 * {"name"="annotation", "dataType"="string", "requirement"="\w+", "description"="The annotation ID"}
94 * }
95 * )
96 *
97 * @ParamConverter("annotation", class="WallabagAnnotationBundle:Annotation")
98 *
99 * @param Annotation $annotation
100 *
101 * @return JsonResponse
102 */
103 public function deleteAnnotationAction(Annotation $annotation)
104 {
105 $this->validateAuthentication();
106
107 return $this->forward('WallabagAnnotationBundle:WallabagAnnotation:deleteAnnotation', [
108 'annotation' => $annotation,
109 ]);
110 }
111}