111
This commit is contained in:
@@ -31,16 +31,4 @@ use Annotation\Attribute;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param static $params
|
||||
* @param mixed $class
|
||||
* @param mixed|null $method
|
||||
* @return array
|
||||
*/
|
||||
public static function execute(mixed $params, mixed $class, mixed $method = null): array
|
||||
{
|
||||
// TODO: Implement execute() method.
|
||||
return [$params->request, $params->response];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,15 +28,5 @@ use Kiri\Kiri;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param mixed $class
|
||||
* @param mixed|null $method
|
||||
* @return bool
|
||||
*/
|
||||
public static function execute(mixed $params, mixed $class, mixed $method = null): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+15
-16
@@ -22,8 +22,19 @@ use Http\IInterface\MiddlewareInterface;
|
||||
* @param string|array $middleware
|
||||
* @throws
|
||||
*/
|
||||
public function __construct(string|array $middleware)
|
||||
public function __construct(public string|array $middleware)
|
||||
{
|
||||
if (is_string($this->middleware)) {
|
||||
$this->middleware = [$this->middleware];
|
||||
}
|
||||
$array = [];
|
||||
foreach ($this->middleware as $value) {
|
||||
$sn = di($value);
|
||||
if (!($sn instanceof MiddlewareInterface)) {
|
||||
continue;
|
||||
}
|
||||
$array[] = [$sn, 'onHandler'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,22 +45,10 @@ use Http\IInterface\MiddlewareInterface;
|
||||
* @return $this
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public static function execute(mixed $params, mixed $class, mixed $method = null): mixed
|
||||
public function execute(mixed $class, mixed $method = null): mixed
|
||||
{
|
||||
if (is_string($params->middleware)) {
|
||||
$params->middleware = [$params->middleware];
|
||||
}
|
||||
$array = [];
|
||||
foreach ($params->middleware as $value) {
|
||||
$sn = di($value);
|
||||
if (!($sn instanceof MiddlewareInterface)) {
|
||||
continue;
|
||||
}
|
||||
$array[] = [$sn, 'onHandler'];
|
||||
}
|
||||
MiddlewareManager::addMiddlewares($class, $method, $array);
|
||||
|
||||
return parent::execute($params, $class, $method);
|
||||
MiddlewareManager::addMiddlewares($class, $method, $this->middleware);
|
||||
return parent::execute($class, $method);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ use Kiri\Kiri;
|
||||
* @param string $method
|
||||
* @param string $version
|
||||
*/
|
||||
public function __construct(string $uri, string $method, string $version = 'v.1.0')
|
||||
public function __construct(public string $uri,public string $method,public string $version = 'v.1.0')
|
||||
{
|
||||
}
|
||||
|
||||
@@ -31,14 +31,14 @@ use Kiri\Kiri;
|
||||
* @throws \Kiri\Exception\NotFindClassException
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
public static function execute(mixed $params, mixed $class, mixed $method = null): Router
|
||||
public function execute(mixed $class, mixed $method = null): Router
|
||||
{
|
||||
// TODO: Implement setHandler() method.
|
||||
$router = Kiri::app()->getRouter();
|
||||
if (is_string($class)) {
|
||||
$class = di($class);
|
||||
}
|
||||
$router->addRoute($params->uri, [$class, $method], strtoupper($params->method));
|
||||
$router->addRoute($this->uri, [$class, $method], strtoupper($this->method));
|
||||
return $router;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user