改名
This commit is contained in:
@@ -34,11 +34,7 @@ abstract class Handler implements RequestHandlerInterface
|
|||||||
protected function execute(ServerRequestInterface $request): ResponseInterface
|
protected function execute(ServerRequestInterface $request): ResponseInterface
|
||||||
{
|
{
|
||||||
if (empty($this->middlewares) || !isset($this->middlewares[$this->offset])) {
|
if (empty($this->middlewares) || !isset($this->middlewares[$this->offset])) {
|
||||||
[$controller, $action] = $this->handler->callback;
|
return $this->dispatcher();
|
||||||
|
|
||||||
$controller = Kiri::getDi()->get($controller);
|
|
||||||
|
|
||||||
return call_user_func([$controller, $action], ...$this->handler->params);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$middleware = $this->middlewares[$this->offset];
|
$middleware = $this->middlewares[$this->offset];
|
||||||
@@ -52,4 +48,21 @@ abstract class Handler implements RequestHandlerInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
protected function dispatcher(): mixed
|
||||||
|
{
|
||||||
|
if ($this->handler->callback instanceof \Closure) {
|
||||||
|
return call_user_func($this->handler->callback, ...$this->handler->params);
|
||||||
|
|
||||||
|
}
|
||||||
|
[$controller, $action] = $this->handler->callback;
|
||||||
|
|
||||||
|
$controller = Kiri::getDi()->get($controller);
|
||||||
|
|
||||||
|
return call_user_func([$controller, $action], ...$this->handler->params);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user