aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ApiBundle/Controller/SearchRestController.php
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2018-10-24 20:11:45 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2019-01-22 20:42:25 +0100
commit019e1acc4962229a538421b6f2b0643d03c1d72c (patch)
tree2d7cb5a5a1908e4db4b17c1cfe405d437928a469 /src/Wallabag/ApiBundle/Controller/SearchRestController.php
parent9133bd02d11c37c98b2c7c979e363cc7bff8f914 (diff)
downloadwallabag-019e1acc4962229a538421b6f2b0643d03c1d72c.tar.gz
wallabag-019e1acc4962229a538421b6f2b0643d03c1d72c.tar.zst
wallabag-019e1acc4962229a538421b6f2b0643d03c1d72c.zip
Factorize sendResponse between Api controllers
And run newer cs fixer
Diffstat (limited to 'src/Wallabag/ApiBundle/Controller/SearchRestController.php')
-rw-r--r--src/Wallabag/ApiBundle/Controller/SearchRestController.php19
1 files changed, 0 insertions, 19 deletions
diff --git a/src/Wallabag/ApiBundle/Controller/SearchRestController.php b/src/Wallabag/ApiBundle/Controller/SearchRestController.php
index 6620107d..f8da0ad4 100644
--- a/src/Wallabag/ApiBundle/Controller/SearchRestController.php
+++ b/src/Wallabag/ApiBundle/Controller/SearchRestController.php
@@ -4,7 +4,6 @@ namespace Wallabag\ApiBundle\Controller;
4 4
5use Hateoas\Configuration\Route; 5use Hateoas\Configuration\Route;
6use Hateoas\Representation\Factory\PagerfantaFactory; 6use Hateoas\Representation\Factory\PagerfantaFactory;
7use JMS\Serializer\SerializationContext;
8use Nelmio\ApiDocBundle\Annotation\ApiDoc; 7use Nelmio\ApiDocBundle\Annotation\ApiDoc;
9use Pagerfanta\Adapter\DoctrineORMAdapter; 8use Pagerfanta\Adapter\DoctrineORMAdapter;
10use Pagerfanta\Pagerfanta; 9use Pagerfanta\Pagerfanta;
@@ -64,22 +63,4 @@ class SearchRestController extends WallabagRestController
64 63
65 return $this->sendResponse($paginatedCollection); 64 return $this->sendResponse($paginatedCollection);
66 } 65 }
67
68 /**
69 * Shortcut to send data serialized in json.
70 *
71 * @param mixed $data
72 *
73 * @return JsonResponse
74 */
75 private function sendResponse($data)
76 {
77 // https://github.com/schmittjoh/JMSSerializerBundle/issues/293
78 $context = new SerializationContext();
79 $context->setSerializeNull(true);
80
81 $json = $this->get('jms_serializer')->serialize($data, 'json', $context);
82
83 return (new JsonResponse())->setJson($json);
84 }
85} 66}