eee
This commit is contained in:
@@ -3,11 +3,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Annotate;
|
||||
|
||||
use Exception;
|
||||
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)]
|
||||
@@ -25,19 +24,21 @@ class Delete extends AbstractRequestMethod implements InjectRouteInterface
|
||||
|
||||
|
||||
/**
|
||||
* @param object $class
|
||||
* @param ReflectionClass $class
|
||||
* @param string $method
|
||||
* @return void
|
||||
* @throws
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function dispatch(object $class, string $method): void
|
||||
public function dispatch(ReflectionClass $class, string $method): void
|
||||
{
|
||||
$controller = \Kiri::getDi()->makeReflection($class);
|
||||
|
||||
// TODO: Implement dispatch() method.
|
||||
$path = '/' . ltrim($this->path, '/');
|
||||
if (!empty($this->version)) {
|
||||
$path = '/' . trim($this->version) . $path;
|
||||
}
|
||||
Router::addRoute(RequestMethod::REQUEST_DELETE, $path, [$class, $method]);
|
||||
Router::addRoute(RequestMethod::REQUEST_DELETE, $path, [$controller, $method]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ 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)]
|
||||
@@ -25,19 +26,21 @@ class Get extends AbstractRequestMethod implements InjectRouteInterface
|
||||
|
||||
|
||||
/**
|
||||
* @param object $class
|
||||
* @param ReflectionClass $class
|
||||
* @param string $method
|
||||
* @return void
|
||||
* @throws
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function dispatch(object $class, string $method): void
|
||||
public function dispatch(ReflectionClass $class, string $method): void
|
||||
{
|
||||
$controller = \Kiri::getDi()->makeReflection($class);
|
||||
|
||||
// TODO: Implement dispatch() method.
|
||||
$path = '/' . ltrim($this->path, '/');
|
||||
if (!empty($this->version)) {
|
||||
$path = '/' . trim($this->version) . $path;
|
||||
}
|
||||
Router::addRoute(RequestMethod::REQUEST_GET, $path, [$class, $method]);
|
||||
Router::addRoute(RequestMethod::REQUEST_GET, $path, [$controller, $method]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,10 +3,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Annotate;
|
||||
|
||||
use Exception;
|
||||
use Kiri;
|
||||
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)]
|
||||
@@ -24,19 +25,20 @@ class Head extends AbstractRequestMethod implements InjectRouteInterface
|
||||
|
||||
|
||||
/**
|
||||
* @param object $class
|
||||
* @param ReflectionClass $class
|
||||
* @param string $method
|
||||
* @return void
|
||||
* @throws
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function dispatch(object $class, string $method): void
|
||||
public function dispatch(ReflectionClass $class, string $method): void
|
||||
{
|
||||
$controller = Kiri::getDi()->makeReflection($class);
|
||||
// TODO: Implement dispatch() method.
|
||||
$path = '/' . ltrim($this->path, '/');
|
||||
if (!empty($this->version)) {
|
||||
$path = '/' . trim($this->version) . $path;
|
||||
}
|
||||
Router::addRoute(RequestMethod::REQUEST_HEAD, $path, [$class, $method]);
|
||||
Router::addRoute(RequestMethod::REQUEST_HEAD, $path, [$controller, $method]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,12 +4,26 @@ declare(strict_types=1);
|
||||
namespace Kiri\Router\Annotate;
|
||||
|
||||
|
||||
use Kiri\Router\Interface\InjectRouteInterface;
|
||||
use ReflectionClass;
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_METHOD)]
|
||||
class Interceptor
|
||||
class Interceptor implements InjectRouteInterface
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ReflectionClass $class
|
||||
* @param string $method
|
||||
* @return void
|
||||
*/
|
||||
public function dispatch(ReflectionClass $class, string $method): void
|
||||
{
|
||||
// TODO: Implement dispatch() method.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,11 +3,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Annotate;
|
||||
|
||||
use Kiri\Di\Interface\InjectPropertyInterface;
|
||||
use Kiri\Router\Base\Middleware as MiddlewareManager;
|
||||
use Kiri\Router\Interface\InjectRouteInterface;
|
||||
use ReflectionClass;
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
|
||||
class Middleware implements InjectPropertyInterface
|
||||
class Middleware implements InjectRouteInterface
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -19,16 +20,15 @@ class Middleware implements InjectPropertyInterface
|
||||
|
||||
|
||||
/**
|
||||
* @param object $class
|
||||
* @param string $property
|
||||
* @param ReflectionClass $class
|
||||
* @param string $method
|
||||
* @return void
|
||||
* @throws
|
||||
*/
|
||||
public function dispatch(object $class, string $property): void
|
||||
public function dispatch(ReflectionClass $class, string $method): void
|
||||
{
|
||||
$middlewareManager = \Kiri::getDi()->get(MiddlewareManager::class);
|
||||
|
||||
$middlewareManager->set($class::class, $property, $this->middleware);
|
||||
$middlewareManager->set($class->getName(), $method, $this->middleware);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3,11 +3,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Annotate;
|
||||
|
||||
use Exception;
|
||||
use Kiri;
|
||||
use Kiri\Router\Constrict\RequestMethod;
|
||||
use Kiri\Router\Interface\InjectRouteInterface;
|
||||
use Kiri\Router\Router;
|
||||
use ReflectionException;
|
||||
use ReflectionClass;
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
|
||||
class Options extends AbstractRequestMethod implements InjectRouteInterface
|
||||
@@ -29,14 +29,16 @@ class Options extends AbstractRequestMethod implements InjectRouteInterface
|
||||
* @return void
|
||||
* @throws
|
||||
*/
|
||||
public function dispatch(object $class, string $method): void
|
||||
public function dispatch(ReflectionClass $class, string $method): void
|
||||
{
|
||||
$controller = Kiri::getDi()->makeReflection($class);
|
||||
|
||||
// TODO: Implement dispatch() method.
|
||||
$path = '/' . ltrim($this->path, '/');
|
||||
if (!empty($this->version)) {
|
||||
$path = '/' . trim($this->version) . $path;
|
||||
}
|
||||
Router::addRoute(RequestMethod::REQUEST_OPTIONS, $path, [$class, $method]);
|
||||
Router::addRoute(RequestMethod::REQUEST_OPTIONS, $path, [$controller, $method]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3,11 +3,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Annotate;
|
||||
|
||||
use Exception;
|
||||
use Kiri;
|
||||
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)]
|
||||
@@ -25,19 +25,21 @@ class Post extends AbstractRequestMethod implements InjectRouteInterface
|
||||
|
||||
|
||||
/**
|
||||
* @param object $class
|
||||
* @param ReflectionClass $class
|
||||
* @param string $method
|
||||
* @return void
|
||||
* @throws
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function dispatch(object $class, string $method): void
|
||||
public function dispatch(ReflectionClass $class, string $method): void
|
||||
{
|
||||
// TODO: Implement dispatch() method.
|
||||
$controller = Kiri::getDi()->makeReflection($class);
|
||||
|
||||
$path = '/' . ltrim($this->path, '/');
|
||||
if (!empty($this->version)) {
|
||||
$path = '/' . trim($this->version) . $path;
|
||||
}
|
||||
Router::addRoute(RequestMethod::REQUEST_POST, $path, [$class, $method]);
|
||||
Router::addRoute(RequestMethod::REQUEST_POST, $path, [$controller, $method]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3,12 +3,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Annotate;
|
||||
|
||||
use Exception;
|
||||
use Kiri;
|
||||
use Kiri\Router\Constrict\RequestMethod;
|
||||
use Kiri\Router\Interface\InjectRouteInterface;
|
||||
use Kiri\Router\OptionsController;
|
||||
use Kiri\Router\Router;
|
||||
use ReflectionException;
|
||||
use ReflectionClass;
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
|
||||
class Put extends AbstractRequestMethod implements InjectRouteInterface
|
||||
@@ -30,14 +29,15 @@ class Put extends AbstractRequestMethod implements InjectRouteInterface
|
||||
* @return void
|
||||
* @throws
|
||||
*/
|
||||
public function dispatch(object $class, string $method): void
|
||||
public function dispatch(ReflectionClass $class, string $method): void
|
||||
{
|
||||
$controller = Kiri::getDi()->makeReflection($class);
|
||||
// TODO: Implement dispatch() method.
|
||||
$path = '/' . ltrim($this->path, '/');
|
||||
if (!empty($this->version)) {
|
||||
$path = '/' . trim($this->version) . $path;
|
||||
}
|
||||
Router::addRoute(RequestMethod::REQUEST_PUT, $path, [$class, $method]);
|
||||
Router::addRoute(RequestMethod::REQUEST_PUT, $path, [$controller, $method]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Kiri\Router\Annotate;
|
||||
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)]
|
||||
@@ -23,17 +24,19 @@ class Route extends AbstractRequestMethod implements InjectRouteInterface
|
||||
|
||||
|
||||
/**
|
||||
* @param object $class
|
||||
* @param ReflectionClass $class
|
||||
* @param string $method
|
||||
* @return void
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function dispatch(object $class, string $method): void
|
||||
public function dispatch(ReflectionClass $class, string $method): void
|
||||
{
|
||||
$controller = \Kiri::getDi()->makeReflection($class);
|
||||
// TODO: Implement dispatch() method.
|
||||
$path = '/' . ltrim($this->path, '/');
|
||||
if (!empty($this->version)) {
|
||||
$path = '/' . trim($this->version) . $path;
|
||||
}
|
||||
Router::addRoute([$this->method], $path, [$class, $method]);
|
||||
Router::addRoute([$this->method], $path, [$controller, $method]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,15 +3,17 @@ declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Interface;
|
||||
|
||||
use ReflectionClass;
|
||||
|
||||
interface InjectRouteInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param object $class
|
||||
* @param ReflectionClass $class
|
||||
* @param string $method
|
||||
* @return void
|
||||
*/
|
||||
public function dispatch(object $class, string $method): void;
|
||||
public function dispatch(ReflectionClass $class, string $method): void;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user