App.php-3
public static function routeCheck($request, array $config)
{
$path = $request->path();
$depr = $config['pathinfo_depr'];
$result = false;
// 路由檢測
$check = !is_null(self::$routeCheck) ? self::$routeCheck : $config['url_route_on'];
if ($check) {
// 開啟路由
if (is_file(RUNTIME_PATH . 'route.php')) {
// 讀取路由快取
$rules = include RUNTIME_PATH . 'route.php';
if (is_array($rules)) {
Route::rules($rules);
}
} else {
$files = $config['route_config_file'];
foreach ($files as $file) {
if (is_file(CONF_PATH . $file . CONF_EXT)) {
// 匯入路由配置
$rules = include CONF_PATH . $file . CONF_EXT;
if (is_array($rules)) {
Route::import($rules);
}
}
}
}
// 路由檢測(根據路由定義返回不同的URL排程)
$result = Route::check($request, $path, $depr, $config['url_domain_deploy']);
$must = !is_null(self::$routeMust) ? self::$routeMust : $config['url_route_must'];
if ($must && false === $result) {
// 路由無效
throw new HttpException(404, 'Route Not Found');
}
}
if (false === $result) {
// 路由無效 解析模組/控制器/操作/引數... 支援控制器自動搜尋
$result = Route::parseUrl($path, $depr, $config['controller_auto_search']);
}
return $result;
}
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/1978/viewspace-2801727/,如需轉載,請註明出處,否則將追究法律責任。