改进Url类对url_convert配置的支持

This commit is contained in:
thinkphp
2018-01-30 19:04:59 +08:00
parent 20b5324815
commit 73f0684065

View File

@@ -210,17 +210,21 @@ class Url
} }
$module = $module ? $module . '/' : ''; $module = $module ? $module . '/' : '';
$controller = Loader::parseName($request->controller()); $controller = $request->controller();
if ('' == $url) { if ('' == $url) {
// 空字符串输出当前的 模块/控制器/操作 // 空字符串输出当前的 模块/控制器/操作
$url = $module . $controller . '/' . $request->action(); $action = $request->action();
} else { } else {
$path = explode('/', $url); $path = explode('/', $url);
$action = Config::get('url_convert') ? strtolower(array_pop($path)) : array_pop($path); $action = array_pop($path);
$controller = empty($path) ? $controller : (Config::get('url_convert') ? Loader::parseName(array_pop($path)) : array_pop($path)); $controller = empty($path) ? $controller : array_pop($path);
$module = empty($path) ? $module : array_pop($path) . '/'; $module = empty($path) ? $module : array_pop($path) . '/';
$url = $module . $controller . '/' . $action;
} }
if (Config::get('url_convert')) {
$action = strtolower($action);
$controller = Loader::parseName($controller);
}
$url = $module . $controller . '/' . $action;
} }
return $url; return $url;
} }