]> git.immae.eu Git - github/wallabag/wallabag.git/blob - src/Wallabag/ApiBundle/Controller/AnnotationRestController.php
API return an error with empty quote
[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 Symfony\Component\HttpFoundation\JsonResponse;
8 use Symfony\Component\HttpFoundation\Request;
9 use Wallabag\AnnotationBundle\Entity\Annotation;
10 use Wallabag\CoreBundle\Entity\Entry;
11
12 class 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 * @return JsonResponse
24 */
25 public function getAnnotationsAction(Entry $entry)
26 {
27 $this->validateAuthentication();
28
29 return $this->forward('WallabagAnnotationBundle:WallabagAnnotation:getAnnotations', [
30 'entry' => $entry,
31 ]);
32 }
33
34 /**
35 * Creates a new annotation.
36 *
37 * @ApiDoc(
38 * requirements={
39 * {"name"="ranges", "dataType"="array", "requirement"="\w+", "description"="The range array for the annotation"},
40 * {"name"="quote", "dataType"="string", "required"=true, "description"="Quote for the annotation"},
41 * {"name"="text", "dataType"="string", "required"=true, "description"=""},
42 * }
43 * )
44 *
45 * @return JsonResponse
46 */
47 public function postAnnotationAction(Request $request, Entry $entry)
48 {
49 $this->validateAuthentication();
50
51 return $this->forward('WallabagAnnotationBundle:WallabagAnnotation:postAnnotation', [
52 'request' => $request,
53 'entry' => $entry,
54 ]);
55 }
56
57 /**
58 * Updates an annotation.
59 *
60 * @ApiDoc(
61 * requirements={
62 * {"name"="annotation", "dataType"="string", "requirement"="\w+", "description"="The annotation ID"}
63 * }
64 * )
65 *
66 * @ParamConverter("annotation", class="WallabagAnnotationBundle:Annotation")
67 *
68 * @return JsonResponse
69 */
70 public function putAnnotationAction(Annotation $annotation, Request $request)
71 {
72 $this->validateAuthentication();
73
74 return $this->forward('WallabagAnnotationBundle:WallabagAnnotation:putAnnotation', [
75 'annotation' => $annotation,
76 'request' => $request,
77 ]);
78 }
79
80 /**
81 * Removes an annotation.
82 *
83 * @ApiDoc(
84 * requirements={
85 * {"name"="annotation", "dataType"="string", "requirement"="\w+", "description"="The annotation ID"}
86 * }
87 * )
88 *
89 * @ParamConverter("annotation", class="WallabagAnnotationBundle:Annotation")
90 *
91 * @return JsonResponse
92 */
93 public function deleteAnnotationAction(Annotation $annotation)
94 {
95 $this->validateAuthentication();
96
97 return $this->forward('WallabagAnnotationBundle:WallabagAnnotation:deleteAnnotation', [
98 'annotation' => $annotation,
99 ]);
100 }
101 }