改名
This commit is contained in:
@@ -4,13 +4,17 @@
|
||||
namespace Annotation\Route;
|
||||
|
||||
|
||||
use Annotation\IAnnotation;
|
||||
use JetBrains\PhpStorm\Pure;
|
||||
use ReflectionException;
|
||||
use Snowflake\Exception\NotFindClassException;
|
||||
use Snowflake\Snowflake;
|
||||
|
||||
/**
|
||||
* Class Middleware
|
||||
* @package Annotation\Route
|
||||
*/
|
||||
#[\Attribute(\Attribute::TARGET_METHOD)] class Middleware
|
||||
#[\Attribute(\Attribute::TARGET_METHOD)] class Middleware implements IAnnotation
|
||||
{
|
||||
|
||||
|
||||
@@ -21,12 +25,27 @@ use Snowflake\Snowflake;
|
||||
*/
|
||||
public function __construct(public string|array $middleware)
|
||||
{
|
||||
if (is_string($this->middleware)) {
|
||||
$this->middleware = [$this->middleware];
|
||||
if (!is_string($this->middleware)) {
|
||||
return;
|
||||
}
|
||||
$this->middleware = [$this->middleware];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array $handler
|
||||
* @return array|string
|
||||
* @throws ReflectionException
|
||||
* @throws NotFindClassException
|
||||
*/
|
||||
public function execute(array $handler): array|string
|
||||
{
|
||||
// TODO: Implement execute() method.
|
||||
foreach ($this->middleware as $key => $item) {
|
||||
$this->middleware[$key] = [Snowflake::createObject($item), 'onHandler'];
|
||||
}
|
||||
return $this->middleware;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user