改进url操作方法的自动转换

This commit is contained in:
thinkphp
2018-04-23 18:19:29 +08:00
parent a3a564bc6d
commit a76d656110
2 changed files with 8 additions and 4 deletions

View File

@@ -555,7 +555,11 @@ class App
// 获取操作名
$actionName = strip_tags($result[2] ?: $config['default_action']);
$actionName = $convert ? strtolower($actionName) : $actionName;
if (!empty($config['action_convert'])) {
$actionName = Loader::parseName($actionName, 1);
} else {
$actionName = $convert ? strtolower($actionName) : $actionName;
}
// 设置当前请求的控制器、操作
$request->controller(Loader::parseName($controller, 1))->action($actionName);

View File

@@ -1506,7 +1506,7 @@ class Route
App::$modulePath = APP_PATH . (Config::get('app_multi_module') ? $request->module() . DS : '');
} else {
// 路由到模块/控制器/操作
$result = self::parseModule($route);
$result = self::parseModule($route, isset($option['convert']) ? $option['convert'] : false);
}
// 开启请求缓存
if ($request->isGet() && isset($option['cache'])) {
@@ -1529,7 +1529,7 @@ class Route
* @param string $url URL地址
* @return array
*/
private static function parseModule($url)
private static function parseModule($url, $convert = false)
{
list($path, $var) = self::parseUrlPath($url);
$action = array_pop($path);
@@ -1543,7 +1543,7 @@ class Route
// 设置当前请求的路由变量
Request::instance()->route($var);
// 路由到模块/控制器/操作
return ['type' => 'module', 'module' => [$module, $controller, $action], 'convert' => false];
return ['type' => 'module', 'module' => [$module, $controller, $action], 'convert' => $convert];
}
/**