mirror of
https://github.com/wallabag/wallabag.git
synced 2025-02-07 23:28:57 +01:00
Fix rest controller merge
This commit is contained in:
parent
5a619812ca
commit
864c1dd23a
111
src/Wallabag/ApiBundle/Controller/AnnotationRestController.php
Normal file
111
src/Wallabag/ApiBundle/Controller/AnnotationRestController.php
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Wallabag\ApiBundle\Controller;
|
||||||
|
|
||||||
|
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
|
||||||
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
|
use Wallabag\CoreBundle\Entity\Entry;
|
||||||
|
use Wallabag\AnnotationBundle\Entity\Annotation;
|
||||||
|
|
||||||
|
class AnnotationRestController extends WallabagRestController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Retrieve annotations for an entry.
|
||||||
|
*
|
||||||
|
* @ApiDoc(
|
||||||
|
* requirements={
|
||||||
|
* {"name"="entry", "dataType"="integer", "requirement"="\w+", "description"="The entry ID"}
|
||||||
|
* }
|
||||||
|
* )
|
||||||
|
*
|
||||||
|
* @param Entry $entry
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function getAnnotationsAction(Entry $entry)
|
||||||
|
{
|
||||||
|
$this->validateAuthentication();
|
||||||
|
|
||||||
|
return $this->forward('WallabagAnnotationBundle:WallabagAnnotation:getAnnotations', [
|
||||||
|
'entry' => $entry,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new annotation.
|
||||||
|
*
|
||||||
|
* @ApiDoc(
|
||||||
|
* requirements={
|
||||||
|
* {"name"="ranges", "dataType"="array", "requirement"="\w+", "description"="The range array for the annotation"},
|
||||||
|
* {"name"="quote", "dataType"="string", "required"=false, "description"="Optional, quote for the annotation"},
|
||||||
|
* {"name"="text", "dataType"="string", "required"=true, "description"=""},
|
||||||
|
* }
|
||||||
|
* )
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @param Entry $entry
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function postAnnotationAction(Request $request, Entry $entry)
|
||||||
|
{
|
||||||
|
$this->validateAuthentication();
|
||||||
|
|
||||||
|
return $this->forward('WallabagAnnotationBundle:WallabagAnnotation:postAnnotation', [
|
||||||
|
'request' => $request,
|
||||||
|
'entry' => $entry,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates an annotation.
|
||||||
|
*
|
||||||
|
* @ApiDoc(
|
||||||
|
* requirements={
|
||||||
|
* {"name"="annotation", "dataType"="string", "requirement"="\w+", "description"="The annotation ID"}
|
||||||
|
* }
|
||||||
|
* )
|
||||||
|
*
|
||||||
|
* @ParamConverter("annotation", class="WallabagAnnotationBundle:Annotation")
|
||||||
|
*
|
||||||
|
* @param Annotation $annotation
|
||||||
|
* @param Request $request
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function putAnnotationAction(Annotation $annotation, Request $request)
|
||||||
|
{
|
||||||
|
$this->validateAuthentication();
|
||||||
|
|
||||||
|
return $this->forward('WallabagAnnotationBundle:WallabagAnnotation:putAnnotation', [
|
||||||
|
'annotation' => $annotation,
|
||||||
|
'request' => $request,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes an annotation.
|
||||||
|
*
|
||||||
|
* @ApiDoc(
|
||||||
|
* requirements={
|
||||||
|
* {"name"="annotation", "dataType"="string", "requirement"="\w+", "description"="The annotation ID"}
|
||||||
|
* }
|
||||||
|
* )
|
||||||
|
*
|
||||||
|
* @ParamConverter("annotation", class="WallabagAnnotationBundle:Annotation")
|
||||||
|
*
|
||||||
|
* @param Annotation $annotation
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function deleteAnnotationAction(Annotation $annotation)
|
||||||
|
{
|
||||||
|
$this->validateAuthentication();
|
||||||
|
|
||||||
|
return $this->forward('WallabagAnnotationBundle:WallabagAnnotation:deleteAnnotation', [
|
||||||
|
'annotation' => $annotation,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
@ -150,6 +150,28 @@ class EntryRestController extends WallabagRestController
|
|||||||
return (new JsonResponse())->setJson($json);
|
return (new JsonResponse())->setJson($json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a single entry as a predefined format.
|
||||||
|
*
|
||||||
|
* @ApiDoc(
|
||||||
|
* requirements={
|
||||||
|
* {"name"="entry", "dataType"="integer", "requirement"="\w+", "description"="The entry ID"}
|
||||||
|
* }
|
||||||
|
* )
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function getEntryExportAction(Entry $entry, Request $request)
|
||||||
|
{
|
||||||
|
$this->validateAuthentication();
|
||||||
|
$this->validateUserAccess($entry->getUser()->getId());
|
||||||
|
|
||||||
|
return $this->get('wallabag_core.helper.entries_export')
|
||||||
|
->setEntries($entry)
|
||||||
|
->updateTitle('entry')
|
||||||
|
->exportAs($request->attributes->get('_format'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an entry.
|
* Create an entry.
|
||||||
*
|
*
|
||||||
|
@ -5,6 +5,8 @@ namespace Wallabag\ApiBundle\Controller;
|
|||||||
use FOS\RestBundle\Controller\FOSRestController;
|
use FOS\RestBundle\Controller\FOSRestController;
|
||||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||||
use Wallabag\CoreBundle\Entity\Entry;
|
use Wallabag\CoreBundle\Entity\Entry;
|
||||||
|
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
|
||||||
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
|
|
||||||
class WallabagRestController extends FOSRestController
|
class WallabagRestController extends FOSRestController
|
||||||
{
|
{
|
||||||
@ -19,6 +21,7 @@ class WallabagRestController extends FOSRestController
|
|||||||
{
|
{
|
||||||
$version = $this->container->getParameter('wallabag_core.version');
|
$version = $this->container->getParameter('wallabag_core.version');
|
||||||
$json = $this->get('serializer')->serialize($version, 'json');
|
$json = $this->get('serializer')->serialize($version, 'json');
|
||||||
|
|
||||||
return (new JsonResponse())->setJson($json);
|
return (new JsonResponse())->setJson($json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,11 @@ tag:
|
|||||||
resource: "WallabagApiBundle:TagRest"
|
resource: "WallabagApiBundle:TagRest"
|
||||||
name_prefix: api_
|
name_prefix: api_
|
||||||
|
|
||||||
|
annotation:
|
||||||
|
type: rest
|
||||||
|
resource: "WallabagApiBundle:AnnotationRest"
|
||||||
|
name_prefix: api_
|
||||||
|
|
||||||
misc:
|
misc:
|
||||||
type: rest
|
type: rest
|
||||||
resource: "WallabagApiBundle:WallabagRest"
|
resource: "WallabagApiBundle:WallabagRest"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user