本文整理汇总了PHP中CUrlManager::createPathInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP CUrlManager::createPathInfo方法的具体用法?PHP CUrlManager::createPathInfo怎么用?PHP CUrlManager::createPathInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUrlManager
的用法示例。
在下文中一共展示了CUrlManager::createPathInfo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createUrl
/**
* Creates a URL based on this rule.
* @param CUrlManager $manager the manager
* @param string $route the route
* @param array $params list of parameters
* @param string $ampersand the token separating name-value pairs in the URL.
* @return mixed the constructed URL or false on error
*/
public function createUrl($manager, $route, $params, $ampersand)
{
if ($this->parsingOnly) {
return false;
}
if ($manager->caseSensitive && $this->caseSensitive === null || $this->caseSensitive) {
$case = '';
} else {
$case = 'i';
}
$tr = array();
if ($route !== $this->route) {
if ($this->routePattern !== null && preg_match($this->routePattern . $case, $route, $matches)) {
foreach ($this->references as $key => $name) {
$tr[$name] = $matches[$key];
}
} else {
return false;
}
}
foreach ($this->defaultParams as $key => $value) {
if (isset($params[$key])) {
if ($params[$key] == $value) {
unset($params[$key]);
} else {
return false;
}
}
}
foreach ($this->params as $key => $value) {
if (!isset($params[$key])) {
return false;
}
}
if ($manager->matchValue && $this->matchValue === null || $this->matchValue) {
foreach ($this->params as $key => $value) {
if (!preg_match('/\\A' . $value . '\\z/u' . $case, $params[$key])) {
return false;
}
}
}
foreach ($this->params as $key => $value) {
$tr["<{$key}>"] = urlencode($params[$key]);
unset($params[$key]);
}
$suffix = $this->urlSuffix === null ? $manager->urlSuffix : $this->urlSuffix;
$url = strtr($this->template, $tr);
if ($this->hasHostInfo) {
$hostInfo = Yii::app()->getRequest()->getHostInfo();
if (stripos($url, $hostInfo) === 0) {
$url = substr($url, strlen($hostInfo));
}
}
if (empty($params)) {
return $url !== '' ? $url . $suffix : $url;
}
if ($this->append) {
$url .= '/' . $manager->createPathInfo($params, '/', '/') . $suffix;
} else {
if ($url !== '') {
$url .= $suffix;
}
$url .= '?' . $manager->createPathInfo($params, '=', $ampersand);
}
return $url;
}