Проинтегрировал свежую версию библиотеки

master v0.0.4
Rinsvent 3 years ago
parent e3a2e933f1
commit 0d805314f1
  1. 12
      composer.lock
  2. 24
      src/EventListener/RequestListener.php

12
composer.lock generated

@ -346,16 +346,16 @@
},
{
"name": "rinsvent/data2dto",
"version": "v0.0.4",
"version": "v0.0.6",
"source": {
"type": "git",
"url": "https://github.com/Rinsvent/data2dto.git",
"reference": "10f1937434ff8e38b21ad54963488e40a4ad2a7d"
"reference": "44ef3f1143fe812578e0231ac5c77d837902d0f5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Rinsvent/data2dto/zipball/10f1937434ff8e38b21ad54963488e40a4ad2a7d",
"reference": "10f1937434ff8e38b21ad54963488e40a4ad2a7d",
"url": "https://api.github.com/repos/Rinsvent/data2dto/zipball/44ef3f1143fe812578e0231ac5c77d837902d0f5",
"reference": "44ef3f1143fe812578e0231ac5c77d837902d0f5",
"shasum": ""
},
"require": {
@ -385,9 +385,9 @@
"description": "Convert data to dto object",
"support": {
"issues": "https://github.com/Rinsvent/data2dto/issues",
"source": "https://github.com/Rinsvent/data2dto/tree/v0.0.4"
"source": "https://github.com/Rinsvent/data2dto/tree/v0.0.6"
},
"time": "2021-08-15T08:40:09+00:00"
"time": "2021-08-16T15:56:23+00:00"
},
{
"name": "symfony/cache",

@ -12,7 +12,6 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\Validator\Validation;
// todo базовая заготовка. Требуется рефакторинг
class RequestListener
{
public function onKernelRequest(RequestEvent $event)
@ -39,9 +38,7 @@ class RequestListener
$request->get('_route'),
$request->getContent(),
$request->query->all(),
$request->request->all(),
$request->headers->all(),
$request->server->all(),
$request->request->all()
);
$errorCollection = $this->validate($requestDTOInstance);
@ -87,9 +84,7 @@ class RequestListener
string $routeName,
string $content,
array $queryParameters = [],
array $parameters = [],
array $headers = [],
array $server = [],
array $parameters = []
) {
$data = [];
try {
@ -103,9 +98,18 @@ class RequestListener
$data = $this->grabDataByJsonPath($data, $requestDTO->jsonPath);
$data2dtoConverter = new Data2DtoConverter();
$result = $data2dtoConverter->convert($data, $requestDTO->className, ['default', 'request', 'source_body', 'route_' . $routeName]);
$result = $data2dtoConverter->convert($headers, $requestDTO->className, ['default', 'request', 'source_headers', 'route_' . $routeName], $result);
$result = $data2dtoConverter->convert($server, $requestDTO->className, ['default', 'request', 'source_server', 'route_' . $routeName], $result);
$result = $data2dtoConverter->convert(
$data,
new $requestDTO->className,
[
'default',
'request',
'request_body',
'request_headers',
'request_server',
'route_' . $routeName
]
);
return $result;
}

Loading…
Cancel
Save