This commit is contained in:
2020-09-04 17:58:26 +08:00
parent 1c3da9d835
commit df59e3976e
2 changed files with 22 additions and 13 deletions
+21 -13
View File
@@ -48,7 +48,6 @@ class Annotation extends \Snowflake\Annotation\Annotation
* @param ReflectionClass $reflect * @param ReflectionClass $reflect
* @param $method * @param $method
* @param $annotations * @param $annotations
* @return mixed|null
* @throws ReflectionException * @throws ReflectionException
*/ */
public function read($node, $reflect, $method, $annotations) public function read($node, $reflect, $method, $annotations)
@@ -57,26 +56,35 @@ class Annotation extends \Snowflake\Annotation\Annotation
$_annotations = $this->getDocCommentAnnotation($annotations, $method->getDocComment()); $_annotations = $this->getDocCommentAnnotation($annotations, $method->getDocComment());
$array = [];
foreach ($_annotations as $keyName => $annotation) { foreach ($_annotations as $keyName => $annotation) {
if (!in_array($keyName, $annotations)) { if (!in_array($keyName, $annotations)) {
continue; continue;
} }
$this->bind($keyName, $node, $annotation);
if ($keyName == 'Method') {
$this->bindMethod($node, $annotation);
} else if ($keyName == 'Middleware') {
$this->bindMiddleware($node, $annotation);
} else if ($keyName == 'Interceptors') {
$this->bindInterceptors($node, $annotation);
}
$array[$keyName] = $this->pop($this->getName(...$annotation));
} }
return $array;
} }
/**
* @param $keyName
* @param $node
* @param $annotation
*/
private function bind($keyName, $node, $annotation)
{
switch ($keyName) {
case 'Method':
$this->bindMethod($node, $annotation);
break;
case 'Middleware':
$this->bindMiddleware($node, $this->pop($this->getName(...$annotation)));
break;
case'Interceptor':
$this->bindInterceptors($node, $this->pop($this->getName(...$annotation)));
break;
}
}
/** /**
* @param $node * @param $node
* @param $annotation * @param $annotation
+1
View File
@@ -468,6 +468,7 @@ class Router extends Application implements RouterInterface
$annotation = $annotation->get('http'); $annotation = $annotation->get('http');
$annotation->registration_notes($prefix . 'Interceptor', 'App\Http\Interceptor'); $annotation->registration_notes($prefix . 'Interceptor', 'App\Http\Interceptor');
$annotation->registration_notes($prefix . 'Limits', 'App\Http\Limits'); $annotation->registration_notes($prefix . 'Limits', 'App\Http\Limits');
$annotation->registration_notes($prefix . 'Middleware', 'App\Http\Middleware');
$this->loadRouteDir(APP_PATH . '/routes'); $this->loadRouteDir(APP_PATH . '/routes');
} }