定义了路由规则的URL原地址禁止访问 改进分组路由的路由自动标识

This commit is contained in:
thinkphp
2016-09-07 12:34:10 +08:00
parent fc0c563706
commit f913450da8
2 changed files with 6 additions and 0 deletions

View File

@@ -61,4 +61,5 @@ return [
'cache write error' => '缓存写入失败',
'sae mc write error' => 'SAE mc 写入错误',
'route name not exists' => '路由标识不存在(或参数不够)',
'invalid request' => '非法请求',
];

View File

@@ -422,6 +422,8 @@ class Route
}
$vars = self::parseVar($key);
$item[] = ['rule' => $key, 'route' => $route, 'var' => $vars, 'option' => $options, 'pattern' => $patterns];
// 设置路由标识
self::$name[$route][] = [$key, $vars, self::$domain];
}
self::$rules['*'][$name] = ['rule' => $item, 'route' => '', 'var' => [], 'option' => $option, 'pattern' => $pattern];
}
@@ -1170,6 +1172,9 @@ class Route
self::parseUrlParams(empty($path) ? '' : implode('/', $path));
// 封装路由
$route = [$module, $controller, $action];
if (isset(self::$name[implode($depr, $route)])) {
throw new HttpException(404, 'invalid request:' . $url);
}
}
return ['type' => 'module', 'module' => $route];
}