本文整理汇总了PHP中UrlManager::removeUrlSuffix方法的典型用法代码示例。如果您正苦于以下问题:PHP UrlManager::removeUrlSuffix方法的具体用法?PHP UrlManager::removeUrlSuffix怎么用?PHP UrlManager::removeUrlSuffix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UrlManager
的用法示例。
在下文中一共展示了UrlManager::removeUrlSuffix方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseUrl
/**
* Parses a URL based on this rule.
* @param UrlManager $manager the URL manager
* @param HttpRequest $request the request object
* @param string $pathInfo path info part of the URL
* @param string $rawPathInfo path info that contains the potential URL suffix
* @return mixed the route that consists of the controller ID and action ID or false on error
*/
public function parseUrl($manager, $request, $pathInfo, $rawPathInfo)
{
if ($this->verb !== null && !in_array($request->getRequestType(), $this->verb, true)) {
return false;
}
if ($manager->caseSensitive && $this->caseSensitive === null || $this->caseSensitive) {
$case = '';
} else {
$case = 'i';
}
if ($this->urlSuffix !== null) {
$pathInfo = $manager->removeUrlSuffix($rawPathInfo, $this->urlSuffix);
}
// URL suffix required, but not found in the requested URL
if ($manager->useStrictParsing && $pathInfo === $rawPathInfo) {
$urlSuffix = $this->urlSuffix === null ? $manager->urlSuffix : $this->urlSuffix;
if ($urlSuffix != '' && $urlSuffix !== '/') {
return false;
}
}
if ($this->hasHostInfo) {
$pathInfo = strtolower($request->getHostInfo()) . rtrim('/' . $pathInfo, '/');
}
$pathInfo .= '/';
if (preg_match($this->pattern . $case, $pathInfo, $matches)) {
foreach ($this->defaultParams as $name => $value) {
if (!isset($_GET[$name])) {
$_REQUEST[$name] = $_GET[$name] = $value;
}
}
$tr = array();
foreach ($matches as $key => $value) {
if (isset($this->references[$key])) {
$tr[$this->references[$key]] = $value;
} else {
if (isset($this->params[$key])) {
$_REQUEST[$key] = $_GET[$key] = $value;
}
}
}
if ($pathInfo !== $matches[0]) {
// there're additional GET params
$manager->parsePathInfo(ltrim(substr($pathInfo, strlen($matches[0])), '/'));
}
if ($this->routePattern !== null) {
return strtr($this->route, $tr);
} else {
return $this->route;
}
} else {
return false;
}
}