diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2016-10-24 10:06:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-24 10:06:12 +0200 |
commit | a1c18418288a9521c980c96fd5defffc757a81c6 (patch) | |
tree | 7331a401bec4f3a4d2a8afc6462ac4fe2eea32f9 /src/Wallabag/ApiBundle/Controller | |
parent | 1e7807e703fd75eceff3df512308b56e452d6dc6 (diff) | |
parent | aa4741091f3f2cc7e4a7ef061a04678597ddeca8 (diff) | |
download | wallabag-a1c18418288a9521c980c96fd5defffc757a81c6.tar.gz wallabag-a1c18418288a9521c980c96fd5defffc757a81c6.tar.zst wallabag-a1c18418288a9521c980c96fd5defffc757a81c6.zip |
Merge pull request #1890 from wallabag/v2-api-annotation-switched
bring annotations to API
Diffstat (limited to 'src/Wallabag/ApiBundle/Controller')
-rw-r--r-- | src/Wallabag/ApiBundle/Controller/WallabagRestController.php | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php index 3437bb9b..a73d44ca 100644 --- a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php +++ b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php | |||
@@ -6,12 +6,14 @@ use FOS\RestBundle\Controller\FOSRestController; | |||
6 | use Hateoas\Configuration\Route as HateoasRoute; | 6 | use Hateoas\Configuration\Route as HateoasRoute; |
7 | use Hateoas\Representation\Factory\PagerfantaFactory; | 7 | use Hateoas\Representation\Factory\PagerfantaFactory; |
8 | use Nelmio\ApiDocBundle\Annotation\ApiDoc; | 8 | use Nelmio\ApiDocBundle\Annotation\ApiDoc; |
9 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; | ||
9 | use Symfony\Component\HttpFoundation\Request; | 10 | use Symfony\Component\HttpFoundation\Request; |
10 | use Symfony\Component\HttpFoundation\JsonResponse; | 11 | use Symfony\Component\HttpFoundation\JsonResponse; |
11 | use Symfony\Component\Routing\Generator\UrlGeneratorInterface; | 12 | use Symfony\Component\Routing\Generator\UrlGeneratorInterface; |
12 | use Symfony\Component\Security\Core\Exception\AccessDeniedException; | 13 | use Symfony\Component\Security\Core\Exception\AccessDeniedException; |
13 | use Wallabag\CoreBundle\Entity\Entry; | 14 | use Wallabag\CoreBundle\Entity\Entry; |
14 | use Wallabag\CoreBundle\Entity\Tag; | 15 | use Wallabag\CoreBundle\Entity\Tag; |
16 | use Wallabag\AnnotationBundle\Entity\Annotation; | ||
15 | 17 | ||
16 | class WallabagRestController extends FOSRestController | 18 | class WallabagRestController extends FOSRestController |
17 | { | 19 | { |
@@ -518,6 +520,104 @@ class WallabagRestController extends FOSRestController | |||
518 | } | 520 | } |
519 | 521 | ||
520 | /** | 522 | /** |
523 | * Retrieve annotations for an entry. | ||
524 | * | ||
525 | * @ApiDoc( | ||
526 | * requirements={ | ||
527 | * {"name"="entry", "dataType"="integer", "requirement"="\w+", "description"="The entry ID"} | ||
528 | * } | ||
529 | * ) | ||
530 | * | ||
531 | * @param Entry $entry | ||
532 | * | ||
533 | * @return JsonResponse | ||
534 | */ | ||
535 | public function getAnnotationsAction(Entry $entry) | ||
536 | { | ||
537 | $this->validateAuthentication(); | ||
538 | |||
539 | return $this->forward('WallabagAnnotationBundle:WallabagAnnotation:getAnnotations', [ | ||
540 | 'entry' => $entry, | ||
541 | ]); | ||
542 | } | ||
543 | |||
544 | /** | ||
545 | * Creates a new annotation. | ||
546 | * | ||
547 | * @ApiDoc( | ||
548 | * requirements={ | ||
549 | * {"name"="ranges", "dataType"="array", "requirement"="\w+", "description"="The range array for the annotation"}, | ||
550 | * {"name"="quote", "dataType"="string", "required"=false, "description"="Optional, quote for the annotation"}, | ||
551 | * {"name"="text", "dataType"="string", "required"=true, "description"=""}, | ||
552 | * } | ||
553 | * ) | ||
554 | * | ||
555 | * @param Request $request | ||
556 | * @param Entry $entry | ||
557 | * | ||
558 | * @return JsonResponse | ||
559 | */ | ||
560 | public function postAnnotationAction(Request $request, Entry $entry) | ||
561 | { | ||
562 | $this->validateAuthentication(); | ||
563 | |||
564 | return $this->forward('WallabagAnnotationBundle:WallabagAnnotation:postAnnotation', [ | ||
565 | 'request' => $request, | ||
566 | 'entry' => $entry, | ||
567 | ]); | ||
568 | } | ||
569 | |||
570 | /** | ||
571 | * Updates an annotation. | ||
572 | * | ||
573 | * @ApiDoc( | ||
574 | * requirements={ | ||
575 | * {"name"="annotation", "dataType"="string", "requirement"="\w+", "description"="The annotation ID"} | ||
576 | * } | ||
577 | * ) | ||
578 | * | ||
579 | * @ParamConverter("annotation", class="WallabagAnnotationBundle:Annotation") | ||
580 | * | ||
581 | * @param Annotation $annotation | ||
582 | * @param Request $request | ||
583 | * | ||
584 | * @return JsonResponse | ||
585 | */ | ||
586 | public function putAnnotationAction(Annotation $annotation, Request $request) | ||
587 | { | ||
588 | $this->validateAuthentication(); | ||
589 | |||
590 | return $this->forward('WallabagAnnotationBundle:WallabagAnnotation:putAnnotation', [ | ||
591 | 'annotation' => $annotation, | ||
592 | 'request' => $request, | ||
593 | ]); | ||
594 | } | ||
595 | |||
596 | /** | ||
597 | * Removes an annotation. | ||
598 | * | ||
599 | * @ApiDoc( | ||
600 | * requirements={ | ||
601 | * {"name"="annotation", "dataType"="string", "requirement"="\w+", "description"="The annotation ID"} | ||
602 | * } | ||
603 | * ) | ||
604 | * | ||
605 | * @ParamConverter("annotation", class="WallabagAnnotationBundle:Annotation") | ||
606 | * | ||
607 | * @param Annotation $annotation | ||
608 | * | ||
609 | * @return JsonResponse | ||
610 | */ | ||
611 | public function deleteAnnotationAction(Annotation $annotation) | ||
612 | { | ||
613 | $this->validateAuthentication(); | ||
614 | |||
615 | return $this->forward('WallabagAnnotationBundle:WallabagAnnotation:deleteAnnotation', [ | ||
616 | 'annotation' => $annotation, | ||
617 | ]); | ||
618 | } | ||
619 | |||
620 | /** | ||
521 | * Retrieve version number. | 621 | * Retrieve version number. |
522 | * | 622 | * |
523 | * @ApiDoc() | 623 | * @ApiDoc() |