コード例 #1
0
 /**
  * Generate a absolute URL to the given path.
  *
  * @param  mixed  $path or SiteTreeNodeInterface Instance
  * @param  mixed  $extra
  * @param  bool  $secure
  * @return string
  */
 public function to($path, $extra = array(), $secure = null)
 {
     // Page object passed
     if (is_object($path) && $path instanceof SiteTreeNodeInterface) {
         if (starts_with($path->getPath(), 'http:')) {
             $path = $path->getPath();
         } else {
             $path = $this->getPathFinder()->toPage($path);
         }
     } elseif (is_string($path) && $this->pageTypes->has($path)) {
         $path = $this->getPathFinder()->toPageType($path);
     } elseif (is_string($path) && $this->currentCmsPathProvider->getCurrentCmsPath()->isCmsPath()) {
         if ($extra && !isset($extra[0])) {
             $extra = array_values($extra);
             $extraPath = implode('/', $extra);
             $path = trim($path, '/') . '/' . trim($extraPath, '/');
             $extra = [];
         }
         if ($path == '/' && $this->getTreeScope()) {
             $path = trim($this->getTreeScope()->getPathPrefix() . $path, '/');
         }
     } elseif ($path == '/' && ($treeScope = $this->getTreeScope())) {
         $path = trim($treeScope->getPathPrefix() . $path, '/');
     }
     return parent::to($path, $extra, $secure);
 }
コード例 #2
0
 public function setNames(RepositoryInterface $repo)
 {
     foreach ($repo->all() as $pageType) {
         if (!$pageType->singularName()) {
             $pageType->setSingularName($this->getTitle($pageType, 1));
             $pageType->setPluralName($this->getTitle($pageType, 2));
         }
         if (!$pageType->description()) {
             $pageType->setDescription($this->getDescription($pageType));
         }
     }
 }
コード例 #3
0
ファイル: PageTypeRouter.php プロジェクト: realholgi/cmsable
 public function setPageType(Route $route, CmsRequestInterface $request)
 {
     if (!($cmsPath = $request->getCmsPath())) {
         return;
     }
     // If a page match did happen the request already has a pagetype
     if ($cmsPath->isCmsPath()) {
         return;
     }
     if (!($pageType = $this->pageTypes->getByRouteName($route->getName()))) {
         return;
     }
     $request->getCmsPath()->setPageType($pageType);
 }
コード例 #4
0
 protected function getPageType(SiteTreeNodeInterface $node)
 {
     return $this->pageTypes->get($node->getPageTypeId());
 }