mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 20:52:48 +08:00
优化Route类的变量传值 统一使用Request类的param方法获取
This commit is contained in:
@@ -135,15 +135,15 @@ class App
|
||||
break;
|
||||
case 'controller':
|
||||
// 执行控制器操作
|
||||
$data = Loader::action($dispatch['controller'], $dispatch['params']);
|
||||
$data = Loader::action($dispatch['controller']);
|
||||
break;
|
||||
case 'method':
|
||||
// 执行回调方法
|
||||
$data = self::invokeMethod($dispatch['method'], $dispatch['params']);
|
||||
$data = self::invokeMethod($dispatch['method']);
|
||||
break;
|
||||
case 'function':
|
||||
// 执行闭包
|
||||
$data = self::invokeFunction($dispatch['function'], $dispatch['params']);
|
||||
$data = self::invokeFunction($dispatch['function']);
|
||||
break;
|
||||
case 'response':
|
||||
$data = $dispatch['response'];
|
||||
@@ -181,12 +181,11 @@ class App
|
||||
* @access public
|
||||
* @param array|string $dispatch 调度信息
|
||||
* @param string $type 调度类型
|
||||
* @param array $params 参数
|
||||
* @return void
|
||||
*/
|
||||
public static function dispatch($dispatch, $type = 'module', $params = [])
|
||||
public static function dispatch($dispatch, $type = 'module')
|
||||
{
|
||||
self::$dispatch = ['type' => $type, $type => $dispatch, 'params' => $params];
|
||||
self::$dispatch = ['type' => $type, $type => $dispatch];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1346,7 +1346,7 @@ class Route
|
||||
}
|
||||
// 路由规则重定向
|
||||
if ($result instanceof Response) {
|
||||
return ['type' => 'response', 'response' => $result, 'params' => $matches];
|
||||
return ['type' => 'response', 'response' => $result];
|
||||
} elseif (is_array($result)) {
|
||||
return $result;
|
||||
}
|
||||
@@ -1354,17 +1354,17 @@ class Route
|
||||
|
||||
if ($route instanceof \Closure) {
|
||||
// 执行闭包
|
||||
$result = ['type' => 'function', 'function' => $route, 'params' => $matches];
|
||||
$result = ['type' => 'function', 'function' => $route];
|
||||
} elseif (0 === strpos($route, '/') || 0 === strpos($route, 'http')) {
|
||||
// 路由到重定向地址
|
||||
$result = ['type' => 'redirect', 'url' => $route, 'status' => isset($option['status']) ? $option['status'] : 301];
|
||||
} elseif (0 === strpos($route, '\\')) {
|
||||
// 路由到方法
|
||||
$method = strpos($route, '@') ? explode('@', $route) : $route;
|
||||
$result = ['type' => 'method', 'method' => $method, 'params' => $matches];
|
||||
$result = ['type' => 'method', 'method' => $method];
|
||||
} elseif (0 === strpos($route, '@')) {
|
||||
// 路由到控制器
|
||||
$result = ['type' => 'controller', 'controller' => substr($route, 1), 'params' => $matches];
|
||||
$result = ['type' => 'controller', 'controller' => substr($route, 1)];
|
||||
} else {
|
||||
// 路由到模块/控制器/操作
|
||||
$result = self::parseModule($route);
|
||||
|
||||
Reference in New Issue
Block a user