本文整理汇总了PHP中Cx\Core\Routing\Url::fromNodeId方法的典型用法代码示例。如果您正苦于以下问题:PHP Url::fromNodeId方法的具体用法?PHP Url::fromNodeId怎么用?PHP Url::fromNodeId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cx\Core\Routing\Url
的用法示例。
在下文中一共展示了Url::fromNodeId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: resolveAlias
/**
* Checks for alias request
* @return Page or null
*/
public function resolveAlias()
{
// This is our alias, if any
$path = $this->url->getSuggestedTargetPath();
$this->path = $path;
//(I) see what the model has for us, aliases only.
$result = $this->pageRepo->getPagesAtPath($path, null, null, false, \Cx\Core\ContentManager\Model\Repository\PageRepository::SEARCH_MODE_ALIAS_ONLY);
//(II) sort out errors
if (!$result) {
// no alias
return null;
}
if (!$result['page']) {
// no alias
return null;
}
if (count($result['page']) != 1) {
throw new ResolverException('Unable to match a single page for this alias (tried path ' . $path . ').');
}
$page = current($result['page']);
if (!$page->isActive()) {
throw new ResolverException('Alias found, but it is not active.');
}
$langDir = $this->url->getLangDir();
$frontendLang = defined('FRONTEND_LANG_ID') ? FRONTEND_LANG_ID : null;
if (!empty($langDir) && $this->pageRepo->getPagesAtPath($langDir . '/' . $path, null, $frontendLang, false, \Cx\Core\ContentManager\Model\Repository\PageRepository::SEARCH_MODE_PAGES_ONLY)) {
return null;
}
$this->page = $page;
$params = $this->url->getParamArray();
if (isset($params['external']) && $params['external'] == 'permanent' || $this->page->isTargetInternal() && preg_match('/[?&]external=permanent/', $this->page->getTarget())) {
if ($this->page->isTargetInternal()) {
$params = array();
if (trim($this->page->getTargetQueryString()) != '') {
$params = explode('&', $this->page->getTargetQueryString());
}
$target = \Cx\Core\Routing\Url::fromNodeId($this->page->getTargetNodeId(), $this->page->getTargetLangId(), $params);
} else {
$target = $this->page->getTarget();
}
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $target);
header('Connection: close');
exit;
}
return $this->page;
}