Доработал обработчик
Проинтегрировал библиотеку Поправил описание библиотеки
This commit is contained in:
parent
eaded296aa
commit
d8fd256977
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "rinsvent/request-bundle",
|
"name": "rinsvent/response-bundle",
|
||||||
"description": "Request bundle",
|
"description": "Response bundle",
|
||||||
"license": "proprietary",
|
"license": "proprietary",
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.0",
|
"php": "^8.0",
|
||||||
@ -11,7 +11,7 @@
|
|||||||
"symfony/cache": "^5.3",
|
"symfony/cache": "^5.3",
|
||||||
"symfony/string": "^5.3",
|
"symfony/string": "^5.3",
|
||||||
"rinsvent/attribute-extractor": "^0.0",
|
"rinsvent/attribute-extractor": "^0.0",
|
||||||
"rinsvent/data2dto": "^0.0",
|
"rinsvent/dto2data": "^0.0",
|
||||||
"doctrine/annotations": "^1.13"
|
"doctrine/annotations": "^1.13"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
5658
composer.lock
generated
5658
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
namespace Rinsvent\ResponseBundle\EventListener;
|
namespace Rinsvent\ResponseBundle\EventListener;
|
||||||
|
|
||||||
|
use Rinsvent\DTO2Data\Dto2DataConverter;
|
||||||
use App\Response\JsonResponse;
|
use Rinsvent\ResponseBundle\Response\JsonResponse;
|
||||||
use App\Serializer\EntitySchemaSerializer;
|
use Symfony\Component\HttpKernel\Event\ResponseEvent;
|
||||||
|
|
||||||
class ResponseListener
|
class ResponseListener
|
||||||
{
|
{
|
||||||
@ -19,16 +19,15 @@ class ResponseListener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$request = $event->getRequest();
|
$data = $response->getRawData();
|
||||||
$data = $response->getData();
|
|
||||||
if ($response->getSchema()) {
|
if (!is_object($data)) {
|
||||||
// $data = $this->entitySchemaSerializer->serializeBySchema($data, $response->getSchema());
|
$response->setData($data);
|
||||||
}
|
return;
|
||||||
|
|
||||||
if ($resultKey = $request->get('_result_key')) {
|
|
||||||
$data = [$resultKey => $data];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$dto2dataConverter = new Dto2DataConverter();
|
||||||
|
$data = $dto2dataConverter->convert($data);
|
||||||
$response->setData($data);
|
$response->setData($data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,14 +4,16 @@ namespace Rinsvent\ResponseBundle\Response;
|
|||||||
|
|
||||||
class JsonResponse extends \Symfony\Component\HttpFoundation\JsonResponse
|
class JsonResponse extends \Symfony\Component\HttpFoundation\JsonResponse
|
||||||
{
|
{
|
||||||
public function __construct($data = null, int $status = 200, array $headers = [], bool $json = false)
|
protected $rawData;
|
||||||
{
|
|
||||||
parent::__construct(null, $status, $headers, $json);
|
|
||||||
$this->data = $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getData()
|
public function __construct($data = null, int $status = 200, array $headers = [], bool $json = false)
|
||||||
{
|
{
|
||||||
return $this->data;
|
parent::__construct(null, $status, $headers, $json);
|
||||||
}
|
$this->rawData = $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRawData()
|
||||||
|
{
|
||||||
|
return $this->rawData;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user