diff --git a/src/Kernel.php b/src/Kernel.php index aa9dfc0..c2f079e 100644 --- a/src/Kernel.php +++ b/src/Kernel.php @@ -34,11 +34,13 @@ public function run(ServerRequestInterface $request, ?StreamInterface $stream = { $this->dispatchConfig->getRouter()->dispatch(function ($data, $args, $middlewares) use ($request, $stream) { + if($args === null) { + $args = $request->getCliArgs(); + } $parts = isset($data[2]) && is_array($data[2]) ? $data[2] : []; $dispatchCode = (int)($data[0] ?? DispatchCodes::FOUND->value); - if($dispatchCode !== DispatchCodes::FOUND->value) { $data['handler'] = function (ServerRequestInterface $req, ResponseInterface $res): ResponseInterface { @@ -75,13 +77,12 @@ function reMap($data, $args, $middlewares) if (isset($data[1]) && $middlewares instanceof ServerRequestInterface) { $item = $data[1]; return [ - ["handler" => $item['controller']], $_REQUEST, ($item['data'] ?? []) + ["handler" => $item['controller']], ($args == null ? $_REQUEST : $args), ($item['data'] ?? []) ]; } if (!is_array($middlewares)) { $middlewares = []; } - if (!is_array($args)) { $args = []; }