From 4ca81db0d0b2810727ab4e49262878340a078987 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCder?= Date: Fri, 15 Mar 2024 00:50:47 +0800 Subject: [PATCH 1/2] Remove queryParams and requestBody from MiddlewareAbstract --- Classes/Middleware/MiddlewareAbstract.php | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/Classes/Middleware/MiddlewareAbstract.php b/Classes/Middleware/MiddlewareAbstract.php index 9bf16cc..aa3a0a4 100644 --- a/Classes/Middleware/MiddlewareAbstract.php +++ b/Classes/Middleware/MiddlewareAbstract.php @@ -5,14 +5,12 @@ namespace JAKOTA\Typo3ToolBox\Middleware; -use InvalidArgumentException; use JAKOTA\Typo3ToolBox\Definition\ContentTypeDefinition; use Psr\Http\Message\ResponseFactoryInterface; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\MiddlewareInterface; use Psr\Http\Server\RequestHandlerInterface; -use RuntimeException; use TYPO3\CMS\Core\Http\Response; use TYPO3\CMS\Core\Information\Typo3Version; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -28,21 +26,11 @@ abstract class MiddlewareAbstract implements MiddlewareInterface { */ protected $pathParams = []; - /** - * @var array - */ - protected $queryParams = []; - /** * @var ServerRequestInterface */ protected $request; - /** - * @var array|object - */ - protected $requestBody = []; - /** * @var ?ResponseInterface */ @@ -60,9 +48,7 @@ public function __construct(ResponseFactoryInterface $responseFactory) { public function checkRequest(string $path, callable $callable, string $method): void { if ($this->request->getMethod() == $method) { if ($this->isPathWithQuery($path) || $this->isPath($path) || $this->isRequestTarget($path)) { - $this->requestBody = $this->request->getParsedBody() ?? []; - $this->queryParams = $this->request->getQueryParams(); - $this->response = $callable($this->queryParams, $this->pathParams[$path] ?? [], $this->requestBody); + $this->response = $callable($this->pathParams[$path] ?? []); } } } From bb505644f5cee87feabe2cbe78b246c799fc509a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCder?= Date: Fri, 15 Mar 2024 00:51:28 +0800 Subject: [PATCH 2/2] Added requestBody to MiddlewareActionAbstract --- Classes/Middleware/MiddlewareActionAbstract.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Classes/Middleware/MiddlewareActionAbstract.php b/Classes/Middleware/MiddlewareActionAbstract.php index b3a4c47..1cbd048 100644 --- a/Classes/Middleware/MiddlewareActionAbstract.php +++ b/Classes/Middleware/MiddlewareActionAbstract.php @@ -38,6 +38,11 @@ abstract class MiddlewareActionAbstract extends ApiAbstract { */ protected array $queryParams = []; + /** + * @var array|object + */ + protected $requestBody = []; + protected ServerRequestInterface $request; protected ?Site $site; @@ -55,6 +60,7 @@ public function __construct(ServerRequestInterface $request, $pathParams) { $this->request = $request; $this->pathParams = $pathParams; $this->queryParams = $this->request->getQueryParams(); + $this->requestBody = $this->request->getParsedBody() ?? []; $this->site = $this->request->getAttribute('site'); $langId = $this->queryParams['L'] ?? false;