改名
This commit is contained in:
@@ -76,11 +76,11 @@ class Annotation extends \Snowflake\Annotation\Annotation
|
|||||||
case 'Method':
|
case 'Method':
|
||||||
$this->bindMethod($node, $annotation);
|
$this->bindMethod($node, $annotation);
|
||||||
break;
|
break;
|
||||||
case 'Middleware':
|
|
||||||
$this->bindMiddleware($node, $this->pop($this->getName(...$annotation)));
|
|
||||||
break;
|
|
||||||
case'Interceptor':
|
case'Interceptor':
|
||||||
$this->bindInterceptors($node, $this->pop($this->getName(...$annotation)));
|
$this->bindInterceptors($node, $annotation);
|
||||||
|
break;
|
||||||
|
case 'Middleware':
|
||||||
|
$this->bindMiddleware($node, $annotation);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -102,6 +102,7 @@ class Annotation extends \Snowflake\Annotation\Annotation
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Node $node
|
* @param Node $node
|
||||||
* @param $annotation
|
* @param $annotation
|
||||||
@@ -112,16 +113,14 @@ class Annotation extends \Snowflake\Annotation\Annotation
|
|||||||
if (!isset($annotation[1][2])) {
|
if (!isset($annotation[1][2])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
$explode = explode(',', $annotation[1][2]);
|
||||||
// $explode = explode(',', $annotation[1][2]);
|
foreach ($explode as $middleware) {
|
||||||
// foreach ($explode as $middleware) {
|
$middleware = 'App\Http\Middleware\\' . $middleware;
|
||||||
// $middleware = 'App\Http\Interceptor\\' . $middleware;
|
if (!class_exists($middleware)) {
|
||||||
// if (!class_exists($middleware)) {
|
continue;
|
||||||
// continue;
|
}
|
||||||
// }
|
$node->addMiddleware($middleware);
|
||||||
// }
|
}
|
||||||
$node->addMiddleware($annotation);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -136,14 +135,15 @@ class Annotation extends \Snowflake\Annotation\Annotation
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// $explode = explode(',', $annotation[1][2]);
|
$explode = explode(',', $annotation[1][2]);
|
||||||
// foreach ($explode as $middleware) {
|
|
||||||
// }
|
|
||||||
$node->addInterceptor($annotation);
|
|
||||||
|
|
||||||
|
[$keyName, $matchs] = $annotation;
|
||||||
|
foreach ($explode as $middleware) {
|
||||||
|
$params = [$keyName, [$matchs[0], $matchs[1], $middleware]];
|
||||||
|
$node->addInterceptor($this->pop($this->getName(...$params)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $controller
|
* @param $controller
|
||||||
* @param $methodName
|
* @param $methodName
|
||||||
|
|||||||
@@ -310,9 +310,15 @@ class Node extends Application
|
|||||||
*/
|
*/
|
||||||
public function addMiddleware(string $class)
|
public function addMiddleware(string $class)
|
||||||
{
|
{
|
||||||
// if (in_array($class, $this->middleware)) {
|
if (is_string($class)) {
|
||||||
// return;
|
$class = Snowflake::createObject($class);
|
||||||
// }
|
if (!($class instanceof \HttpServer\IInterface\Middleware)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$class = [$class, 'handler'];
|
||||||
|
} else if (!is_callable($class, true)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
$this->middleware[] = $class;
|
$this->middleware[] = $class;
|
||||||
$this->restructure();
|
$this->restructure();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user