本文整理汇总了PHP中RequestUtil::GetMethod方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestUtil::GetMethod方法的具体用法?PHP RequestUtil::GetMethod怎么用?PHP RequestUtil::GetMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RequestUtil
的用法示例。
在下文中一共展示了RequestUtil::GetMethod方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetRoute
/**
* @inheritdocs
*/
public function GetRoute($uri = "")
{
// reset the uri cache
$this->uri = '';
if ($uri == "") {
$uri = RequestUtil::GetMethod() . ":" . $this->GetUri();
}
// literal match check
if (isset($this->routeMap[$uri])) {
// expects mapped values to be in the form: Controller.Model
list($controller, $method) = explode(".", $this->routeMap[$uri]["route"]);
$this->matchedRoute = array("key" => $this->routeMap[$uri], "route" => $this->routeMap[$uri]["route"], "params" => isset($this->routeMap[$uri]["params"]) ? $this->routeMap[$uri]["params"] : array());
return array($controller, $method);
}
// loop through the route map for wild cards:
foreach ($this->routeMap as $key => $value) {
$unalteredKey = $key;
// convert wild cards to RegEx.
// currently only ":any" and ":num" are supported wild cards
$key = str_replace(':any', '.+', $key);
$key = str_replace(':num', '[0-9]+', $key);
// check for RegEx match
if (preg_match('#^' . $key . '$#', $uri)) {
$this->matchedRoute = array("key" => $unalteredKey, "route" => $value["route"], "params" => isset($value["params"]) ? $value["params"] : array());
// expects mapped values to be in the form: Controller.Model
list($controller, $method) = explode(".", $value["route"]);
return array($controller, $method);
}
}
// this is a page-not-found route
$this->matchedRoute = array("key" => '', "route" => '', "params" => array());
// if we haven't returned by now, we've found no match:
return explode('.', self::$ROUTE_NOT_FOUND, 2);
}
示例2: GetRoute
/**
* Returns the controller and method for the given URI
*
* @param string the url, if not provided will be obtained using the current URL
* @return array($controller,$method)
*/
public function GetRoute($uri = "")
{
$match = '';
$qs = $uri ? $uri : (array_key_exists('QUERY_STRING', $_SERVER) ? $_SERVER['QUERY_STRING'] : '');
$parsed = explode('&', $qs, 2);
$action = $parsed[0];
if (strpos($action, '=') > -1 || !$action) {
// the querystring is empty or the first param is a named param, which we ignore
$match = $this->defaultAction;
} else {
// otherwise we have a route. see if we have a match in the routemap, otherwise return the 'not found' route
$method = RequestUtil::GetMethod();
$route = $method . ':' . $action;
$match = array_key_exists($route, $this->routes) ? $this->routes[$route]['route'] : self::$ROUTE_NOT_FOUND;
}
return explode('.', $match, 2);
}