改进路由到类的方法的地址写法

This commit is contained in:
thinkphp
2016-06-07 18:46:07 +08:00
parent 451e7f0dda
commit 0b2359e856
2 changed files with 4 additions and 4 deletions

View File

@@ -1041,7 +1041,8 @@ class Route
$result = ['type' => 'redirect', 'url' => $url, 'status' => (is_array($route) && isset($route[1])) ? $route[1] : 301];
} elseif (0 === strpos($url, '\\')) {
// 路由到方法
$result = ['type' => 'method', 'method' => is_array($route) ? [$url, $route[1]] : $url, 'params' => $matches];
$method = strpos($url, '@') ? explode('@', $url) : $url;
$result = ['type' => 'method', 'method' => $method, 'params' => $matches];
} elseif (0 === strpos($url, '@')) {
// 路由到控制器
$result = ['type' => 'controller', 'controller' => substr($url, 1), 'params' => $matches];

View File

@@ -145,6 +145,7 @@ class Handle
// 不显示详细错误信息
$data['message'] = Config::get('error_message');
}
//保留一层
while (ob_get_level() > 1) {
ob_end_clean();
@@ -154,8 +155,7 @@ class Handle
extract($data);
include Config::get('exception_tmpl');
// 获取并清空缓存
$content = ob_get_clean();
$content = ob_get_clean();
$response = new Response($content, 'html');
if ($exception instanceof HttpException) {
@@ -167,7 +167,6 @@ class Handle
$statusCode = 500;
}
$response->code($statusCode);
return $response;
}