当前位置: 首页>>代码示例>>PHP>>正文


PHP Url::fromNodeId方法代码示例

本文整理汇总了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;
 }
开发者ID:hbdsklf,项目名称:LimeCMS,代码行数:51,代码来源:Resolver.class.php


注:本文中的Cx\Core\Routing\Url::fromNodeId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。