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