本文整理汇总了PHP中Routes::routes方法的典型用法代码示例。如果您正苦于以下问题:PHP Routes::routes方法的具体用法?PHP Routes::routes怎么用?PHP Routes::routes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Routes
的用法示例。
在下文中一共展示了Routes::routes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
public static function register($routes)
{
self::$routes = array_merge((array) $routes, self::$routes);
}
示例2: findClosestRoute
/**
* Find the route that matches the closest.
*/
private function findClosestRoute($request_uri)
{
$Routes = Routes::routes();
$closeness = 0;
$ret = new stdClass();
$controller_action = null;
foreach ($Routes->export() as $key => $value) {
//var_dump($Routes->export());
$value = (object) $value;
if ($request_uri == $value->path) {
$ret = $value;
break;
}
$current = similar_text($request_uri, $value->path);
if ($current > $closeness) {
$closeness = $current;
$ret = $value;
}
$controller = preg_replace('/([^\\s])([A-Z])/', '\\1-\\2', $value->controller);
$first = $second = '/' . strtolower($controller) . '/' . $value->action;
$second = $second . '/';
if ($first == $request_uri || $second == $request_uri) {
$controller_action = $value;
}
}
return array('ret' => $ret, 'controller-action' => $controller_action);
}