This commit is contained in:
2023-04-17 14:00:53 +08:00
parent 8b22769b85
commit f220892b4a
9 changed files with 5 additions and 69 deletions
-2
View File
@@ -35,8 +35,6 @@ class Delete extends AbstractRequestMethod implements InjectRouteInterface
{
// TODO: Implement dispatch() method.
Router::addRoute(RequestMethod::REQUEST_DELETE, $this->path, [$class, $method]);
$this->registerMiddleware($class, $method);
}
-15
View File
@@ -1,15 +0,0 @@
<?php
declare(strict_types=1);
namespace Kiri\Router\Annotate;
#[\Attribute(\Attribute::TARGET_METHOD)]
class Filter
{
public function __construct()
{
}
}
-2
View File
@@ -36,8 +36,6 @@ class Get extends AbstractRequestMethod implements InjectRouteInterface
{
// TODO: Implement dispatch() method.
Router::addRoute(RequestMethod::REQUEST_GET, $this->path, [$class, $method]);
$this->registerMiddleware($class, $method);
}
}
+5
View File
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Kiri\Router\Annotate;
use Kiri\Di\Interface\InjectPropertyInterface;
use Kiri\Router\Base\Middleware as MiddlewareManager;
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
class Middleware implements InjectPropertyInterface
@@ -21,9 +22,13 @@ class Middleware implements InjectPropertyInterface
* @param object $class
* @param string $property
* @return void
* @throws
*/
public function dispatch(object $class, string $property): void
{
$middlewareManager = \Kiri::getDi()->get(MiddlewareManager::class);
$middlewareManager->set($class::class, $property, $this->middleware);
}
-2
View File
@@ -36,8 +36,6 @@ class Options extends AbstractRequestMethod implements InjectRouteInterface
{
// TODO: Implement dispatch() method.
Router::addRoute(RequestMethod::REQUEST_OPTIONS, $this->path, [$class, $method]);
$this->registerMiddleware($class, $method);
}
-42
View File
@@ -1,42 +0,0 @@
<?php
declare(strict_types=1);
namespace Kiri\Router\Annotate;
use Exception;
use Kiri\Router\Interface\InjectRouteInterface;
use Kiri\Router\Router;
use ReflectionException;
#[\Attribute(\Attribute::TARGET_METHOD)]
class Other extends AbstractRequestMethod implements InjectRouteInterface
{
/**
* @param string $method
* @param string $path
* @param string $formValidate
*/
public function __construct(readonly public string $method, string $path, string $formValidate = '')
{
}
/**
* @param object $class
* @param string $method
* @return void
* @throws ReflectionException
* @throws Exception
*/
public function dispatch(object $class, string $method): void
{
// TODO: Implement dispatch() method.
Router::addRoute([$this->method], $this->path, [$class, $method]);
$this->registerMiddleware($class, $method);
}
}
-2
View File
@@ -35,8 +35,6 @@ class Post extends AbstractRequestMethod implements InjectRouteInterface
{
// TODO: Implement dispatch() method.
Router::addRoute(RequestMethod::REQUEST_POST, $this->path, [$class, $method]);
$this->registerMiddleware($class, $method);
}
-2
View File
@@ -35,8 +35,6 @@ class Put extends AbstractRequestMethod implements InjectRouteInterface
{
// TODO: Implement dispatch() method.
Router::addRoute(RequestMethod::REQUEST_PUT, $this->path, [$class, $method]);
$this->registerMiddleware($class, $method);
}
}
-2
View File
@@ -30,7 +30,5 @@ class Route extends AbstractRequestMethod implements InjectRouteInterface
{
// TODO: Implement dispatch() method.
Router::addRoute($this->method, $this->path, [$class, $method]);
$this->registerMiddleware($class, $method);
}
}