forked from wallabag/wallabag
Factorize sendResponse between Api controllers
And run newer cs fixer
This commit is contained in:
@ -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 Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@ -773,24 +772,6 @@ class EntryRestController extends WallabagRestController
|
||||
return $this->sendResponse($results);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve value from the request.
|
||||
* Used for POST & PATCH on a an entry.
|
||||
|
||||
Reference in New Issue
Block a user