diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-11-03 17:29:16 +0100 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-11-03 17:29:16 +0100 |
commit | 864c1dd23a4aa9e5f412302694d9303070dca6dc (patch) | |
tree | 9d84fbb6898d86e0e3bf7aaf193db89c45e88097 /src/Wallabag/ApiBundle/Controller/AnnotationRestController.php | |
parent | 5a619812ca3eb05a82a023ccdaee13501eb8d45f (diff) | |
download | wallabag-864c1dd23a4aa9e5f412302694d9303070dca6dc.tar.gz wallabag-864c1dd23a4aa9e5f412302694d9303070dca6dc.tar.zst wallabag-864c1dd23a4aa9e5f412302694d9303070dca6dc.zip |
Fix rest controller merge
Diffstat (limited to 'src/Wallabag/ApiBundle/Controller/AnnotationRestController.php')
-rw-r--r-- | src/Wallabag/ApiBundle/Controller/AnnotationRestController.php | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/src/Wallabag/ApiBundle/Controller/AnnotationRestController.php b/src/Wallabag/ApiBundle/Controller/AnnotationRestController.php new file mode 100644 index 00000000..2dd26c07 --- /dev/null +++ b/src/Wallabag/ApiBundle/Controller/AnnotationRestController.php | |||
@@ -0,0 +1,111 @@ | |||
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\Request; | ||
8 | use Symfony\Component\HttpFoundation\JsonResponse; | ||
9 | use Wallabag\CoreBundle\Entity\Entry; | ||
10 | use Wallabag\AnnotationBundle\Entity\Annotation; | ||
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 | * @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 | } | ||