本文整理汇总了PHP中Dispatcher::params方法的典型用法代码示例。如果您正苦于以下问题:PHP Dispatcher::params方法的具体用法?PHP Dispatcher::params怎么用?PHP Dispatcher::params使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dispatcher
的用法示例。
在下文中一共展示了Dispatcher::params方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getParams
/**
* 获得动作参数
*/
public static function getParams()
{
//此条URL规则作废URL http://sk.com/sk80/index.php?job=archive&action=archive&arg=alias_google-out-china&page=1
//URL http://sk.com/sk80/index.php?job=archive&action=archive&alias=google-out-china&page=1
//处理有分页的情况
$parmas = array();
$params = self::$request;
if (array_key_exists('job', $params)) {
unset($params['job']);
}
if (array_key_exists('action', $params)) {
unset($params['action']);
}
return self::$params = $params;
}
示例2: dispatch
public static function dispatch($requested_url = null, $default = null)
{
Flash::init();
// If no url passed, we will get the first key from the _GET array
// that way, index.php?/controller/action/var1&email=example@example.com
// requested_url will be equal to: /controller/action/var1
if ($requested_url === null) {
$pos = strpos($_SERVER['QUERY_STRING'], '&');
if ($pos !== false) {
$requested_url = substr($_SERVER['QUERY_STRING'], 0, $pos);
} else {
$requested_url = $_SERVER['QUERY_STRING'];
}
}
// If no URL is requested (due to someone accessing admin section for the first time)
// AND $default is setAllow for a default tab
if ($requested_url == null && $default != null) {
$requested_url = $default;
}
// Requested url MUST start with a slash (for route convention)
if (strpos($requested_url, '/') !== 0) {
$requested_url = '/' . $requested_url;
}
self::$requested_url = $requested_url;
// This is only trace for debugging
self::$status['requested_url'] = $requested_url;
// Make the first split of the current requested_url
self::$params = self::splitUrl($requested_url);
// Do we even have any custom routing to deal with?
if (count(self::$routes) === 0) {
return self::executeAction(self::getController(), self::getAction(), self::getParams());
}
// Is there a literal match? If so we're done
if (isset(self::$routes[$requested_url])) {
self::$params = self::splitUrl(self::$routes[$requested_url]);
return self::executeAction(self::getController(), self::getAction(), self::getParams());
}
// Loop through the route array looking for wildcards
foreach (self::$routes as $route => $uri) {
// Convert wildcards to regex
if (strpos($route, ':') !== false) {
$route = str_replace(':any', '(.+)', str_replace(':num', '([0-9]+)', $route));
}
// Does the regex match?
if (preg_match('#^' . $route . '$#', $requested_url)) {
// Do we have a back-reference?
if (strpos($uri, '$') !== false && strpos($route, '(') !== false) {
$uri = preg_replace('#^' . $route . '$#', $uri, $requested_url);
}
self::$params = self::splitUrl($uri);
// We found it, so we can break the loop now!
break;
}
}
return self::executeAction(self::getController(), self::getAction(), self::getParams());
}