This commit is contained in:
2021-03-19 16:32:34 +08:00
parent fc18533f7c
commit 0c98f8858d
5 changed files with 112 additions and 5 deletions
+1
View File
@@ -35,6 +35,7 @@ class Loader extends BaseObject
/**
* @param $path
* @param $namespace
* @throws ComponentException
*/
public function loader($path, $namespace)
{
+16 -3
View File
@@ -5,6 +5,11 @@ namespace Annotation\Route;
use Annotation\Attribute;
use HttpServer\HttpFilter;
use ReflectionException;
use Snowflake\Exception\ComponentException;
use Snowflake\Exception\NotFindClassException;
use Snowflake\Snowflake;
/**
* Class Filter
@@ -15,9 +20,9 @@ use Annotation\Attribute;
/**
* Filter constructor.
* @param string $uri
* @param array $rules
*/
public function __construct(public string $uri)
public function __construct(public array $rules)
{
}
@@ -25,10 +30,18 @@ use Annotation\Attribute;
/**
* @param array $handler
* @return array
* @throws ReflectionException
* @throws ComponentException
* @throws NotFindClassException
*/
public function execute(array $handler): array
{
// TODO: Implement execute() method.
[$class, $method] = $handler;
/** @var HttpFilter $filter */
$filter = Snowflake::app()->get('filter');
$filter->register(get_class($class), $method, $this->rules);
return $handler;
}