路由地址到控制器方式 也支持动态变量

This commit is contained in:
thinkphp
2016-01-14 09:33:46 +08:00
parent 8e6bd84741
commit e21b21ce36

View File

@@ -567,10 +567,16 @@ 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' => $route, 'params' => $matches];
} elseif (0 === strpos($url, '@')) {
// 路由到控制器
if (strpos($url, ':')) {
// 传递动态参数
foreach ($matches as $key => $val) {
$url = str_replace(':' . $key, $val, $url);
}
}
$result = ['type' => 'controller', 'controller' => substr($url, 1), 'params' => $matches];
} else {
// 解析路由地址