改名
This commit is contained in:
+21
-15
@@ -4,13 +4,16 @@
|
||||
namespace Annotation\Route;
|
||||
|
||||
|
||||
use Annotation\IAnnotation;
|
||||
use ReflectionException;
|
||||
use Snowflake\Exception\NotFindClassException;
|
||||
use Snowflake\Snowflake;
|
||||
|
||||
/**
|
||||
* Class Interceptor
|
||||
* @package Annotation\Route
|
||||
*/
|
||||
#[\Attribute(\Attribute::TARGET_METHOD)] class After
|
||||
#[\Attribute(\Attribute::TARGET_METHOD)] class After implements IAnnotation
|
||||
{
|
||||
|
||||
|
||||
@@ -18,27 +21,30 @@ use Snowflake\Snowflake;
|
||||
* Interceptor constructor.
|
||||
* @param \HttpServer\IInterface\After|\HttpServer\IInterface\After[] $after
|
||||
* @throws
|
||||
* if ($object instanceof Interceptor) {
|
||||
$classes[$key] = [$object, 'Interceptor'];
|
||||
}
|
||||
if ($object instanceof Limits) {
|
||||
$classes[$key] = [$object, 'next'];
|
||||
}
|
||||
if ($object instanceof After) {
|
||||
$classes[$key] = [$object, 'onHandler'];
|
||||
}
|
||||
if ($object instanceof Middleware) {
|
||||
$classes[$key] = [$object, 'onHandler'];
|
||||
}
|
||||
*/
|
||||
public function __construct(public string|array $after)
|
||||
{
|
||||
if (is_string($this->after)) {
|
||||
$this->after = [$this->after];
|
||||
if (!is_string($this->after)) {
|
||||
return;
|
||||
}
|
||||
$this->after = [$this->after];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array $handler
|
||||
* @return array|string
|
||||
* @throws ReflectionException
|
||||
* @throws NotFindClassException
|
||||
*/
|
||||
public function execute(array $handler): array|string
|
||||
{
|
||||
// TODO: Implement execute() method.
|
||||
foreach ($this->after as $key => $item) {
|
||||
$this->after[$key] = [Snowflake::createObject($item), 'onHandler'];
|
||||
}
|
||||
return $this->after;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user