This commit is contained in:
2020-09-07 02:15:51 +08:00
parent db6497f256
commit 0b3036e082
3 changed files with 74 additions and 2 deletions
@@ -82,6 +82,9 @@ class Annotation extends \Snowflake\Annotation\Annotation
case 'Middleware':
$this->bindMiddleware($node, $annotation);
break;
case 'Limits':
$this->bindLimits($node, $annotation);
break;
}
}
@@ -144,6 +147,27 @@ class Annotation extends \Snowflake\Annotation\Annotation
}
}
/**
* @param Node $node
* @param $annotation
* @throws
*/
private function bindLimits($node, $annotation)
{
if (!isset($annotation[1][2])) {
return;
}
$explode = explode(',', $annotation[1][2]);
[$keyName, $matchs] = $annotation;
foreach ($explode as $middleware) {
$params = [$keyName, [$matchs[0], $matchs[1], $middleware]];
$node->addLimits($this->pop($this->getName(...$params)));
}
}
/**
* @param $controller
* @param $methodName