This commit is contained in:
2023-12-18 22:23:17 +08:00
parent 7c0ab8c639
commit a51b666303
13 changed files with 67 additions and 141 deletions
+5 -8
View File
@@ -3,14 +3,12 @@ declare(strict_types=1);
namespace Kiri\Router\Annotate;
use Kiri\Di\Interface\InjectMethodInterface;
use Kiri\Router\Constrict\RequestMethod;
use Kiri\Router\Interface\InjectRouteInterface;
use Kiri\Router\Router;
use ReflectionClass;
use ReflectionException;
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
class Delete extends AbstractRequestMethod implements InjectRouteInterface
class Delete extends AbstractRequestMethod implements InjectMethodInterface
{
@@ -24,14 +22,13 @@ class Delete extends AbstractRequestMethod implements InjectRouteInterface
/**
* @param ReflectionClass $class
* @param string $class
* @param string $method
* @return void
* @throws ReflectionException
*/
public function dispatch(ReflectionClass $class, string $method): void
public function dispatch(string $class, string $method): void
{
$controller = \Kiri::getDi()->makeReflection($class);
$controller = \Kiri::getDi()->get($class);
// TODO: Implement dispatch() method.
$path = '/' . ltrim($this->path, '/');
+5 -10
View File
@@ -3,16 +3,12 @@ declare(strict_types=1);
namespace Kiri\Router\Annotate;
use Exception;
use Kiri\Di\Interface\InjectMethodInterface;
use Kiri\Router\Constrict\RequestMethod;
use Kiri\Router\Interface\InjectRouteInterface;
use Kiri\Router\OptionsController;
use Kiri\Router\Router;
use ReflectionClass;
use ReflectionException;
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
class Get extends AbstractRequestMethod implements InjectRouteInterface
class Get extends AbstractRequestMethod implements InjectMethodInterface
{
@@ -26,14 +22,13 @@ class Get extends AbstractRequestMethod implements InjectRouteInterface
/**
* @param ReflectionClass $class
* @param string $class
* @param string $method
* @return void
* @throws ReflectionException
*/
public function dispatch(ReflectionClass $class, string $method): void
public function dispatch(string $class, string $method): void
{
$controller = \Kiri::getDi()->makeReflection($class);
$controller = \Kiri::getDi()->get($class);
// TODO: Implement dispatch() method.
$path = '/' . ltrim($this->path, '/');
+5 -8
View File
@@ -5,13 +5,11 @@ namespace Kiri\Router\Annotate;
use Kiri;
use Kiri\Router\Constrict\RequestMethod;
use Kiri\Router\Interface\InjectRouteInterface;
use Kiri\Di\Interface\InjectMethodInterface;
use Kiri\Router\Router;
use ReflectionClass;
use ReflectionException;
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
class Head extends AbstractRequestMethod implements InjectRouteInterface
class Head extends AbstractRequestMethod implements InjectMethodInterface
{
@@ -25,14 +23,13 @@ class Head extends AbstractRequestMethod implements InjectRouteInterface
/**
* @param ReflectionClass $class
* @param string $class
* @param string $method
* @return void
* @throws ReflectionException
*/
public function dispatch(ReflectionClass $class, string $method): void
public function dispatch(string $class, string $method): void
{
$controller = Kiri::getDi()->makeReflection($class);
$controller = Kiri::getDi()->get($class);
// TODO: Implement dispatch() method.
$path = '/' . ltrim($this->path, '/');
if (!empty($this->version)) {
+4 -5
View File
@@ -4,11 +4,10 @@ declare(strict_types=1);
namespace Kiri\Router\Annotate;
use Kiri\Router\Interface\InjectRouteInterface;
use ReflectionClass;
use Kiri\Di\Interface\InjectMethodInterface;
#[\Attribute(\Attribute::TARGET_METHOD)]
class Interceptor implements InjectRouteInterface
class Interceptor implements InjectMethodInterface
{
public function __construct()
@@ -17,11 +16,11 @@ class Interceptor implements InjectRouteInterface
/**
* @param ReflectionClass $class
* @param string $class
* @param string $method
* @return void
*/
public function dispatch(ReflectionClass $class, string $method): void
public function dispatch(string $class, string $method): void
{
// TODO: Implement dispatch() method.
}
+5 -6
View File
@@ -3,12 +3,11 @@ declare(strict_types=1);
namespace Kiri\Router\Annotate;
use Kiri\Di\Interface\InjectMethodInterface;
use Kiri\Router\Base\Middleware as MiddlewareManager;
use Kiri\Router\Interface\InjectRouteInterface;
use ReflectionClass;
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
class Middleware implements InjectRouteInterface
class Middleware implements InjectMethodInterface
{
/**
@@ -20,15 +19,15 @@ class Middleware implements InjectRouteInterface
/**
* @param ReflectionClass $class
* @param string $class
* @param string $method
* @return void
*/
public function dispatch(ReflectionClass $class, string $method): void
public function dispatch(string $class, string $method): void
{
$middlewareManager = \Kiri::getDi()->get(MiddlewareManager::class);
$middlewareManager->set($class->getName(), $method, $this->middleware);
$middlewareManager->set($class, $method, $this->middleware);
}
+4 -5
View File
@@ -5,12 +5,11 @@ namespace Kiri\Router\Annotate;
use Kiri;
use Kiri\Router\Constrict\RequestMethod;
use Kiri\Router\Interface\InjectRouteInterface;
use Kiri\Router\Router;
use ReflectionClass;
use Kiri\Di\Interface\InjectMethodInterface;
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
class Options extends AbstractRequestMethod implements InjectRouteInterface
class Options extends AbstractRequestMethod implements InjectMethodInterface
{
@@ -29,9 +28,9 @@ class Options extends AbstractRequestMethod implements InjectRouteInterface
* @return void
* @throws
*/
public function dispatch(ReflectionClass $class, string $method): void
public function dispatch(string $class, string $method): void
{
$controller = Kiri::getDi()->makeReflection($class);
$controller = Kiri::getDi()->get($class);
// TODO: Implement dispatch() method.
$path = '/' . ltrim($this->path, '/');
+5 -8
View File
@@ -5,13 +5,11 @@ namespace Kiri\Router\Annotate;
use Kiri;
use Kiri\Router\Constrict\RequestMethod;
use Kiri\Router\Interface\InjectRouteInterface;
use Kiri\Router\Router;
use ReflectionClass;
use ReflectionException;
use Kiri\Di\Interface\InjectMethodInterface;
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
class Post extends AbstractRequestMethod implements InjectRouteInterface
class Post extends AbstractRequestMethod implements InjectMethodInterface
{
@@ -25,15 +23,14 @@ class Post extends AbstractRequestMethod implements InjectRouteInterface
/**
* @param ReflectionClass $class
* @param string $class
* @param string $method
* @return void
* @throws ReflectionException
*/
public function dispatch(ReflectionClass $class, string $method): void
public function dispatch(string $class, string $method): void
{
// TODO: Implement dispatch() method.
$controller = Kiri::getDi()->makeReflection($class);
$controller = Kiri::getDi()->get($class);
$path = '/' . ltrim($this->path, '/');
if (!empty($this->version)) {
+8 -7
View File
@@ -5,12 +5,14 @@ namespace Kiri\Router\Annotate;
use Kiri;
use Kiri\Router\Constrict\RequestMethod;
use Kiri\Router\Interface\InjectRouteInterface;
use Kiri\Router\Router;
use ReflectionClass;
use Kiri\Di\Interface\InjectMethodInterface;
/**
*
*/
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
class Put extends AbstractRequestMethod implements InjectRouteInterface
class Put extends AbstractRequestMethod implements InjectMethodInterface
{
@@ -24,14 +26,13 @@ class Put extends AbstractRequestMethod implements InjectRouteInterface
/**
* @param object $class
* @param string $class
* @param string $method
* @return void
* @throws
*/
public function dispatch(ReflectionClass $class, string $method): void
public function dispatch(string $class, string $method): void
{
$controller = Kiri::getDi()->makeReflection($class);
$controller = Kiri::getDi()->get($class);
// TODO: Implement dispatch() method.
$path = '/' . ltrim($this->path, '/');
if (!empty($this->version)) {
+5 -9
View File
@@ -3,13 +3,11 @@
namespace Kiri\Router\Annotate;
use Kiri\Router\Constrict\RequestMethod;
use Kiri\Router\Interface\InjectRouteInterface;
use Kiri\Router\Router;
use ReflectionClass;
use ReflectionException;
use Kiri\Di\Interface\InjectMethodInterface;
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
class Route extends AbstractRequestMethod implements InjectRouteInterface
class Route extends AbstractRequestMethod implements InjectMethodInterface
{
@@ -24,15 +22,13 @@ class Route extends AbstractRequestMethod implements InjectRouteInterface
/**
* @param ReflectionClass $class
* @param string $class
* @param string $method
* @return void
* @throws ReflectionException
*/
public function dispatch(ReflectionClass $class, string $method): void
public function dispatch(string $class, string $method): void
{
$controller = \Kiri::getDi()->makeReflection($class);
// TODO: Implement dispatch() method.
$controller = \Kiri::getDi()->get($class);
$path = '/' . ltrim($this->path, '/');
if (!empty($this->version)) {
$path = '/' . trim($this->version) . $path;