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] ?? []); } } } 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;