变更
This commit is contained in:
+11
-9
@@ -52,12 +52,11 @@ class RouterCollector implements \ArrayAccess, \IteratorAggregate
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param RequestMethod[] $method
|
* @param array $method
|
||||||
* @param string $route
|
* @param string $route
|
||||||
* @param string|Closure $closure
|
* @param string|array|Closure $closure
|
||||||
* @throws
|
|
||||||
*/
|
*/
|
||||||
public function addRoute(array $method, string $route, string|Closure $closure)
|
public function addRoute(array $method, string $route, string|array|Closure $closure)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$route = $this->_splicing_routing($route);
|
$route = $this->_splicing_routing($route);
|
||||||
@@ -80,17 +79,20 @@ class RouterCollector implements \ArrayAccess, \IteratorAggregate
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $closure
|
* @param string|array $closure
|
||||||
* @param ControllerInterpreter $interpreter
|
* @param ControllerInterpreter $interpreter
|
||||||
* @return Handler
|
* @return Handler
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
*/
|
*/
|
||||||
private function resolve(string $closure, ControllerInterpreter $interpreter): Handler
|
private function resolve(string|array $closure, ControllerInterpreter $interpreter): Handler
|
||||||
{
|
{
|
||||||
[$className, $method] = explode('@', $closure);
|
if (is_array($closure)) {
|
||||||
|
[$class, $method] = $closure;
|
||||||
$class = Kiri::getDi()->get($this->resetName($className));
|
} else {
|
||||||
|
[$className, $method] = explode('@', $closure);
|
||||||
|
|
||||||
|
$class = Kiri::getDi()->get($this->resetName($className));
|
||||||
|
}
|
||||||
return $interpreter->addRouteByString($class, $method);
|
return $interpreter->addRouteByString($class, $method);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user