2016-11-03 16:29:16 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Wallabag\ApiBundle\Controller;
|
|
|
|
|
|
|
|
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
|
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
|
|
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
2017-07-01 07:52:38 +00:00
|
|
|
use Symfony\Component\HttpFoundation\Request;
|
2016-11-03 16:29:16 +00:00
|
|
|
use Wallabag\AnnotationBundle\Entity\Annotation;
|
2017-07-01 07:52:38 +00:00
|
|
|
use Wallabag\CoreBundle\Entity\Entry;
|
2016-11-03 16:29:16 +00:00
|
|
|
|
|
|
|
class AnnotationRestController extends WallabagRestController
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Retrieve annotations for an entry.
|
|
|
|
*
|
|
|
|
* @ApiDoc(
|
|
|
|
* requirements={
|
|
|
|
* {"name"="entry", "dataType"="integer", "requirement"="\w+", "description"="The entry ID"}
|
|
|
|
* }
|
|
|
|
* )
|
|
|
|
*
|
|
|
|
* @return JsonResponse
|
|
|
|
*/
|
|
|
|
public function getAnnotationsAction(Entry $entry)
|
|
|
|
{
|
|
|
|
$this->validateAuthentication();
|
|
|
|
|
2022-08-25 21:18:48 +00:00
|
|
|
return $this->forward('Wallabag\AnnotationBundle\Controller\WallabagAnnotationController::getAnnotationsAction', [
|
2016-11-03 16:29:16 +00:00
|
|
|
'entry' => $entry,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new annotation.
|
|
|
|
*
|
|
|
|
* @ApiDoc(
|
|
|
|
* requirements={
|
|
|
|
* {"name"="ranges", "dataType"="array", "requirement"="\w+", "description"="The range array for the annotation"},
|
2019-11-24 09:44:26 +00:00
|
|
|
* {"name"="quote", "dataType"="string", "description"="The annotated text"},
|
|
|
|
* {"name"="text", "dataType"="string", "required"=true, "description"="Content of annotation"},
|
2016-11-03 16:29:16 +00:00
|
|
|
* }
|
|
|
|
* )
|
|
|
|
*
|
|
|
|
* @return JsonResponse
|
|
|
|
*/
|
|
|
|
public function postAnnotationAction(Request $request, Entry $entry)
|
|
|
|
{
|
|
|
|
$this->validateAuthentication();
|
|
|
|
|
2022-08-25 21:18:48 +00:00
|
|
|
return $this->forward('Wallabag\AnnotationBundle\Controller\WallabagAnnotationController::postAnnotationAction', [
|
2016-11-03 16:29:16 +00:00
|
|
|
'request' => $request,
|
|
|
|
'entry' => $entry,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates an annotation.
|
|
|
|
*
|
|
|
|
* @ApiDoc(
|
|
|
|
* requirements={
|
|
|
|
* {"name"="annotation", "dataType"="string", "requirement"="\w+", "description"="The annotation ID"}
|
|
|
|
* }
|
|
|
|
* )
|
|
|
|
*
|
2022-08-25 20:25:41 +00:00
|
|
|
* @ParamConverter("annotation", class="Wallabag\AnnotationBundle\Entity\Annotation")
|
2016-11-03 16:29:16 +00:00
|
|
|
*
|
|
|
|
* @return JsonResponse
|
|
|
|
*/
|
|
|
|
public function putAnnotationAction(Annotation $annotation, Request $request)
|
|
|
|
{
|
|
|
|
$this->validateAuthentication();
|
|
|
|
|
2022-08-25 21:18:48 +00:00
|
|
|
return $this->forward('Wallabag\AnnotationBundle\Controller\WallabagAnnotationController::putAnnotationAction', [
|
2016-11-03 16:29:16 +00:00
|
|
|
'annotation' => $annotation,
|
|
|
|
'request' => $request,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes an annotation.
|
|
|
|
*
|
|
|
|
* @ApiDoc(
|
|
|
|
* requirements={
|
|
|
|
* {"name"="annotation", "dataType"="string", "requirement"="\w+", "description"="The annotation ID"}
|
|
|
|
* }
|
|
|
|
* )
|
|
|
|
*
|
2022-08-25 20:25:41 +00:00
|
|
|
* @ParamConverter("annotation", class="Wallabag\AnnotationBundle\Entity\Annotation")
|
2016-11-03 16:29:16 +00:00
|
|
|
*
|
|
|
|
* @return JsonResponse
|
|
|
|
*/
|
|
|
|
public function deleteAnnotationAction(Annotation $annotation)
|
|
|
|
{
|
|
|
|
$this->validateAuthentication();
|
|
|
|
|
2022-08-25 21:18:48 +00:00
|
|
|
return $this->forward('Wallabag\AnnotationBundle\Controller\WallabagAnnotationController::deleteAnnotationAction', [
|
2016-11-03 16:29:16 +00:00
|
|
|
'annotation' => $annotation,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|