改名
This commit is contained in:
@@ -444,15 +444,19 @@ class Node extends Application
|
|||||||
*/
|
*/
|
||||||
private function each($array, $_temp)
|
private function each($array, $_temp)
|
||||||
{
|
{
|
||||||
if (empty($array)) {
|
if (!is_array($array)) {
|
||||||
return $_temp;
|
return $_temp;
|
||||||
}
|
}
|
||||||
foreach ($array as $class) {
|
foreach ($array as $class) {
|
||||||
if (!is_array($class)) {
|
if (is_array($class)) {
|
||||||
$_temp[] = Snowflake::createObject($class);
|
|
||||||
} else {
|
|
||||||
$_temp = $this->each($class, $_temp);
|
$_temp = $this->each($class, $_temp);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!class_exists($class)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$_temp[] = Snowflake::createObject($class);
|
||||||
}
|
}
|
||||||
return $_temp;
|
return $_temp;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,8 +38,20 @@ class Router extends Application implements RouterInterface
|
|||||||
public $methods = ['get', 'post', 'options', 'put', 'delete', 'receive'];
|
public $methods = ['get', 'post', 'options', 'put', 'delete', 'receive'];
|
||||||
|
|
||||||
|
|
||||||
|
public $middleware = null;
|
||||||
|
|
||||||
public $useTree = false;
|
public $useTree = false;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Closure $middleware
|
||||||
|
*/
|
||||||
|
public function setMiddleware(\Closure $middleware): void
|
||||||
|
{
|
||||||
|
$this->middleware = $middleware;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws ConfigException
|
* @throws ConfigException
|
||||||
* 初始化函数路径
|
* 初始化函数路径
|
||||||
@@ -291,9 +303,10 @@ class Router extends Application implements RouterInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$name = array_column($this->groupTacks, 'middleware');
|
$name = array_column($this->groupTacks, 'middleware');
|
||||||
if (!empty($name) && $name = array_filter($name)) {
|
if (!empty($this->middleware) && $this->middleware instanceof \Closure) {
|
||||||
$node->bindMiddleware($name);
|
array_unshift($name, $this->middleware);
|
||||||
}
|
}
|
||||||
|
$node->bindMiddleware($name);
|
||||||
|
|
||||||
$options = array_column($this->groupTacks, 'options');
|
$options = array_column($this->groupTacks, 'options');
|
||||||
if (!empty($options) && is_array($options)) {
|
if (!empty($options) && is_array($options)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user