改名
This commit is contained in:
+35
-35
@@ -276,7 +276,7 @@ class Node extends HttpService
|
||||
throw new Exception('method ' . $action . ' not exists at ' . $controller . '.');
|
||||
}
|
||||
|
||||
$this->annotationInject($reflect->getName(), $action);
|
||||
static::annotationInject($this, $reflect->getName(), $action);
|
||||
|
||||
return [$reflect->newInstance(), $action];
|
||||
} catch (Throwable $exception) {
|
||||
@@ -287,40 +287,6 @@ class Node extends HttpService
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $className
|
||||
* @param string $action
|
||||
* @return $this
|
||||
* @throws ComponentException
|
||||
* @throws NotFindClassException
|
||||
* @throws ReflectionException
|
||||
* @throws Exception
|
||||
*/
|
||||
private function annotationInject(string $className, string $action): static
|
||||
{
|
||||
$annotation = annotation()->getMethods($className, $action);
|
||||
if (empty($annotation)) {
|
||||
return $this;
|
||||
}
|
||||
foreach ($annotation as $name => $attribute) {
|
||||
var_dump($this->path . ':' . get_class($attribute));
|
||||
if ($attribute instanceof \Annotation\Route\Interceptor) {
|
||||
$this->addInterceptor($attribute->interceptor);
|
||||
}
|
||||
if ($attribute instanceof \Annotation\Route\After) {
|
||||
$this->addAfter($attribute->after);
|
||||
}
|
||||
if ($attribute instanceof RMiddleware) {
|
||||
$this->addMiddleware($attribute->middleware);
|
||||
}
|
||||
if ($attribute instanceof \Annotation\Route\Limits) {
|
||||
$this->addLimits($attribute->limits);
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Closure|array|string $handler
|
||||
* @throws Exception
|
||||
@@ -339,6 +305,40 @@ class Node extends HttpService
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Node $node
|
||||
* @param string $className
|
||||
* @param string $action
|
||||
* @return Node
|
||||
* @throws ComponentException
|
||||
* @throws NotFindClassException
|
||||
* @throws ReflectionException
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function annotationInject(Node $node, string $className, string $action): Node
|
||||
{
|
||||
$annotation = annotation()->getMethods($className, $action);
|
||||
if (empty($annotation)) {
|
||||
return $node;
|
||||
}
|
||||
foreach ($annotation as $name => $attribute) {
|
||||
if ($attribute instanceof \Annotation\Route\Interceptor) {
|
||||
$node->addInterceptor($attribute->interceptor);
|
||||
}
|
||||
if ($attribute instanceof \Annotation\Route\After) {
|
||||
$node->addAfter($attribute->after);
|
||||
}
|
||||
if ($attribute instanceof RMiddleware) {
|
||||
$node->addMiddleware($attribute->middleware);
|
||||
}
|
||||
if ($attribute instanceof \Annotation\Route\Limits) {
|
||||
$node->addLimits($attribute->limits);
|
||||
}
|
||||
}
|
||||
return $node;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Closure|array|string $handler
|
||||
* @throws Exception
|
||||
|
||||
Reference in New Issue
Block a user