aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
diff options
context:
space:
mode:
authorJérémy Benoist <j0k3r@users.noreply.github.com>2019-01-23 09:19:37 +0100
committerGitHub <noreply@github.com>2019-01-23 09:19:37 +0100
commitc6024246b744e411175318065f7c396bbb5a213e (patch)
tree635cbb8cd75888990e90c52317db72068196291d /src/Wallabag/ApiBundle/Controller/WallabagRestController.php
parenta8f4f7665c98753cca15140c283d49e0aa4cd0ab (diff)
parent801042544444d58580d87d04d5602797027153fc (diff)
downloadwallabag-c6024246b744e411175318065f7c396bbb5a213e.tar.gz
wallabag-c6024246b744e411175318065f7c396bbb5a213e.tar.zst
wallabag-c6024246b744e411175318065f7c396bbb5a213e.zip
Merge pull request #3627 from craig0990/feature/add-search-api-endpoint2.4
Add a basic Search REST endpoint
Diffstat (limited to 'src/Wallabag/ApiBundle/Controller/WallabagRestController.php')
-rw-r--r--src/Wallabag/ApiBundle/Controller/WallabagRestController.php19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
index 3c7ad0cf..f18b0910 100644
--- a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
+++ b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
@@ -3,6 +3,7 @@
3namespace Wallabag\ApiBundle\Controller; 3namespace Wallabag\ApiBundle\Controller;
4 4
5use FOS\RestBundle\Controller\FOSRestController; 5use FOS\RestBundle\Controller\FOSRestController;
6use JMS\Serializer\SerializationContext;
6use Nelmio\ApiDocBundle\Annotation\ApiDoc; 7use Nelmio\ApiDocBundle\Annotation\ApiDoc;
7use Symfony\Component\HttpFoundation\JsonResponse; 8use Symfony\Component\HttpFoundation\JsonResponse;
8use Symfony\Component\Security\Core\Exception\AccessDeniedException; 9use Symfony\Component\Security\Core\Exception\AccessDeniedException;
@@ -64,4 +65,22 @@ class WallabagRestController extends FOSRestController
64 throw $this->createAccessDeniedException('Access forbidden. Entry user id: ' . $requestUserId . ', logged user id: ' . $user->getId()); 65 throw $this->createAccessDeniedException('Access forbidden. Entry user id: ' . $requestUserId . ', logged user id: ' . $user->getId());
65 } 66 }
66 } 67 }
68
69 /**
70 * Shortcut to send data serialized in json.
71 *
72 * @param mixed $data
73 *
74 * @return JsonResponse
75 */
76 protected function sendResponse($data)
77 {
78 // https://github.com/schmittjoh/JMSSerializerBundle/issues/293
79 $context = new SerializationContext();
80 $context->setSerializeNull(true);
81
82 $json = $this->get('jms_serializer')->serialize($data, 'json', $context);
83
84 return (new JsonResponse())->setJson($json);
85 }
67} 86}