mirror of
https://github.com/wallabag/wallabag.git
synced 2025-08-31 18:31:02 +00:00
Factorize sendResponse between Api controllers
And run newer cs fixer
This commit is contained in:
parent
9133bd02d1
commit
019e1acc49
4 changed files with 21 additions and 41 deletions
|
@ -4,7 +4,6 @@ namespace Wallabag\ApiBundle\Controller;
|
|||
|
||||
use Hateoas\Configuration\Route;
|
||||
use Hateoas\Representation\Factory\PagerfantaFactory;
|
||||
use JMS\Serializer\SerializationContext;
|
||||
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
|
||||
use Pagerfanta\Adapter\DoctrineORMAdapter;
|
||||
use Pagerfanta\Pagerfanta;
|
||||
|
@ -64,22 +63,4 @@ class SearchRestController extends WallabagRestController
|
|||
|
||||
return $this->sendResponse($paginatedCollection);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcut to send data serialized in json.
|
||||
*
|
||||
* @param mixed $data
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
private function sendResponse($data)
|
||||
{
|
||||
// https://github.com/schmittjoh/JMSSerializerBundle/issues/293
|
||||
$context = new SerializationContext();
|
||||
$context->setSerializeNull(true);
|
||||
|
||||
$json = $this->get('jms_serializer')->serialize($data, 'json', $context);
|
||||
|
||||
return (new JsonResponse())->setJson($json);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue