<?php
namespace App\Model\Controlpanel\Response;
use App\Application\DTO\ControlPanel\Api\JsonApi\JsonApiDocument;
use App\Application\Service\Factory\SerializerFactory;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
/**
* @deprecated
*/
class JsonApiResponse extends JsonResponse
{
public function __construct(?JsonApiDocument $data = null, int $status = 200, array $headers = [], bool $json = true)
{
$serializer = SerializerFactory::getJsonAPISerializer();
$headers['Content-Type'] = 'application/vnd.api+json';
$jsonApiDocument = null;
if ($data instanceof JsonApiDocument) {
$jsonApiDocument = $serializer->serialize($data, JsonEncoder::FORMAT, ['groups' => ['read']]);
}
parent::__construct($jsonApiDocument, $status, $headers, $json);
}
}