变更
This commit is contained in:
@@ -1,41 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Kiri\Router;
|
||||
|
||||
class ActionManager
|
||||
{
|
||||
|
||||
|
||||
private static array $array = [];
|
||||
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
* @param string $method
|
||||
* @param Handler $handler
|
||||
* @return void
|
||||
*/
|
||||
public static function add(string $class, string $method, Handler $handler): void
|
||||
{
|
||||
if (!isset(static::$array[$class])) {
|
||||
static::$array[$class] = [$method => []];
|
||||
}
|
||||
static::$array[$class][$method] = $handler;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
* @param string $method
|
||||
* @return array|null
|
||||
*/
|
||||
public static function get(string $class, string $method): ?Handler
|
||||
{
|
||||
if (isset(static::$array[$class])) {
|
||||
return static::$array[$class][$method] ?? null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Aspect;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Aspect;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Aspect;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Aspect;
|
||||
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Kiri\Router\Aspect;
|
||||
|
||||
|
||||
|
||||
class TestAspect extends AbstractsAspect
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param OnJoinPointInterface $joinPoint
|
||||
* @return mixed
|
||||
*/
|
||||
public function process(OnJoinPointInterface $joinPoint): mixed
|
||||
{
|
||||
|
||||
$result = $joinPoint->process();
|
||||
|
||||
var_dump('111');
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Base;
|
||||
|
||||
use Kiri\Inject\Route\TestResponse;
|
||||
use Kiri\Router\Handler;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Base;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Base;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Base;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Base;
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Base;
|
||||
|
||||
use Kiri\Message\Constrict\ResponseInterface;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
class MethodErrorController extends Controller
|
||||
{
|
||||
@@ -13,6 +15,6 @@ class MethodErrorController extends Controller
|
||||
*/
|
||||
public function fail(): ResponseInterface
|
||||
{
|
||||
return $this->response->failure(405, "method allow.");
|
||||
return $this->response->withStatus(405, "method allow.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Base;
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Base;
|
||||
|
||||
use Kiri\Message\Constrict\ResponseInterface;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
class NotFoundController extends Controller
|
||||
{
|
||||
@@ -13,7 +15,7 @@ class NotFoundController extends Controller
|
||||
*/
|
||||
public function fail(): ResponseInterface
|
||||
{
|
||||
return $this->response->failure(404, "not found page.");
|
||||
return $this->response->withStatus(404, "not found page.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Constrict;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Constrict;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Constrict;
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Constrict;
|
||||
|
||||
enum RequestMethod
|
||||
{
|
||||
|
||||
|
||||
|
||||
case REQUEST_POST;
|
||||
case REQUEST_GET;
|
||||
case REQUEST_HEAD;
|
||||
case REQUEST_OPTIONS;
|
||||
case REQUEST_DELETE;
|
||||
case REQUEST_PUT;
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getString(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::REQUEST_POST => 'POST',
|
||||
self::REQUEST_GET => 'GET',
|
||||
self::REQUEST_HEAD => 'HEAD',
|
||||
self::REQUEST_OPTIONS => 'OPTIONS',
|
||||
self::REQUEST_DELETE => 'DELETE',
|
||||
self::REQUEST_PUT => 'PUT'
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Constrict;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Constrict;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Inject;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Inject;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Inject;
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Inject;
|
||||
|
||||
use Exception;
|
||||
use Kiri\Annotation\Route\RequestMethod;
|
||||
use Kiri\Router\Constrict\RequestMethod;
|
||||
use Kiri\Router\InjectRouteInterface;
|
||||
use Kiri\Router\Router;
|
||||
use ReflectionException;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Inject;
|
||||
|
||||
|
||||
+2
-1
@@ -1,9 +1,10 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Inject;
|
||||
|
||||
use Exception;
|
||||
use Kiri\Annotation\Route\RequestMethod;
|
||||
use Kiri\Router\Constrict\RequestMethod;
|
||||
use Kiri\Router\InjectRouteInterface;
|
||||
use Kiri\Router\Router;
|
||||
use ReflectionException;
|
||||
|
||||
+2
-1
@@ -1,9 +1,10 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Inject;
|
||||
|
||||
use Exception;
|
||||
use Kiri\Annotation\Route\RequestMethod;
|
||||
use Kiri\Router\Constrict\RequestMethod;
|
||||
use Kiri\Router\InjectRouteInterface;
|
||||
use Kiri\Router\Router;
|
||||
use ReflectionException;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Inject;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Inject;
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Inject;
|
||||
|
||||
use Exception;
|
||||
use Kiri\Annotation\Route\RequestMethod;
|
||||
use Kiri\Router\Constrict\RequestMethod;
|
||||
use Kiri\Router\InjectRouteInterface;
|
||||
use Kiri\Router\Router;
|
||||
use ReflectionException;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Inject;
|
||||
|
||||
|
||||
+2
-1
@@ -1,9 +1,10 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Inject;
|
||||
|
||||
use Exception;
|
||||
use Kiri\Annotation\Route\RequestMethod;
|
||||
use Kiri\Router\Constrict\RequestMethod;
|
||||
use Kiri\Router\InjectRouteInterface;
|
||||
use Kiri\Router\Router;
|
||||
use ReflectionException;
|
||||
|
||||
+2
-1
@@ -1,9 +1,10 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Inject;
|
||||
|
||||
use Exception;
|
||||
use Kiri\Annotation\Route\RequestMethod;
|
||||
use Kiri\Router\Constrict\RequestMethod;
|
||||
use Kiri\Router\InjectRouteInterface;
|
||||
use Kiri\Router\Router;
|
||||
use Kiri\Router\Base\Middleware as MiddlewareManager;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Inject;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Interface;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Interface;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Interface;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router;
|
||||
|
||||
|
||||
+2
-1
@@ -1,11 +1,12 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router;
|
||||
|
||||
use Closure;
|
||||
use Exception;
|
||||
use Kiri;
|
||||
use Kiri\Annotation\Route\RequestMethod;
|
||||
use Kiri\Router\Constrict\RequestMethod;
|
||||
use ReflectionException;
|
||||
|
||||
const ROUTER_TYPE_HTTP = 'http';
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router;
|
||||
|
||||
|
||||
@@ -7,12 +9,12 @@ use Closure;
|
||||
use Exception;
|
||||
use Kiri;
|
||||
use Kiri\Router\Base\NotFoundController;
|
||||
use Kiri\Router\Constrict\RequestMethod;
|
||||
use ReflectionException;
|
||||
use Throwable;
|
||||
use Traversable;
|
||||
use Kiri\Router\Base\Middleware;
|
||||
use Kiri\Core\HashMap;
|
||||
use Kiri\Annotation\Route\RequestMethod;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Validator\Inject;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Validator\Inject;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Validator\Inject;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Validator\Inject;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Validator\Inject;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Validator\Inject;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Validator\Inject;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Validator\Inject;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Validator\Inject;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Validator\Inject;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Validator\Inject;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Validator\Inject;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Validator\Inject;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Validator\Inject;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Validator\Inject;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Validator;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Validator;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user