本文整理匯總了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;
}