diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2018-10-24 20:11:45 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2019-01-22 20:42:25 +0100 |
commit | 019e1acc4962229a538421b6f2b0643d03c1d72c (patch) | |
tree | 2d7cb5a5a1908e4db4b17c1cfe405d437928a469 /src/Wallabag/ApiBundle/Controller/SearchRestController.php | |
parent | 9133bd02d11c37c98b2c7c979e363cc7bff8f914 (diff) | |
download | wallabag-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.php | 19 |
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 | ||
5 | use Hateoas\Configuration\Route; | 5 | use Hateoas\Configuration\Route; |
6 | use Hateoas\Representation\Factory\PagerfantaFactory; | 6 | use Hateoas\Representation\Factory\PagerfantaFactory; |
7 | use JMS\Serializer\SerializationContext; | ||
8 | use Nelmio\ApiDocBundle\Annotation\ApiDoc; | 7 | use Nelmio\ApiDocBundle\Annotation\ApiDoc; |
9 | use Pagerfanta\Adapter\DoctrineORMAdapter; | 8 | use Pagerfanta\Adapter\DoctrineORMAdapter; |
10 | use Pagerfanta\Pagerfanta; | 9 | use 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 | } |