改名
This commit is contained in:
@@ -338,20 +338,38 @@ class Router extends HttpService implements RouterInterface
|
|||||||
|
|
||||||
$array = [];
|
$array = [];
|
||||||
foreach ($middleware as $value) {
|
foreach ($middleware as $value) {
|
||||||
if (is_string($value)) {
|
if (is_array($value)) {
|
||||||
$value = Snowflake::createObject($value);
|
foreach ($value as $item) {
|
||||||
if (!($value instanceof Middleware)) {
|
$array[] = $this->getMiddlewareInstance($item);
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
$array[] = [$value, 'onHandler'];
|
|
||||||
} else {
|
} else {
|
||||||
$array[] = $value;
|
$array[] = $this->getMiddlewareInstance($value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $array;
|
return $array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $value
|
||||||
|
* @return Closure|array|null
|
||||||
|
* @throws NotFindClassException
|
||||||
|
* @throws ReflectionException
|
||||||
|
*/
|
||||||
|
private function getMiddlewareInstance($value): null|Closure|array
|
||||||
|
{
|
||||||
|
if (is_string($value)) {
|
||||||
|
$value = Snowflake::createObject($value);
|
||||||
|
if (!($value instanceof Middleware)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return [$value, 'onHandler'];
|
||||||
|
} else {
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $method
|
* @param $method
|
||||||
* @return array
|
* @return array
|
||||||
|
|||||||
Reference in New Issue
Block a user