getCurrentDomain() публичный Метод

public getCurrentDomain ( ) : Domain
Результат Jarves\Model\Domain
Пример #1
0
 /**
  * @param array $options
  *
  * @return null|Model\Node
  *
  * @throws Exceptions\BundleNotFoundException
  * @throws \Exception
  */
 public function get($options)
 {
     $options['id'] = isset($options['id']) ? $options['id'] : false;
     $options['level'] = isset($options['level']) ? $options['level'] : false;
     //        $withFolders = (isset($options['folders']) && $options['folders'] == 1) ? true : false;
     $navigation = false;
     if (!$navigation && $options['id'] != 'breadcrumb' && ($options['id'] || $options['level'])) {
         if ($options['id'] + 0 > 0) {
             $navigation = $this->pageStack->getPage($options['id'] + 0);
             if (!$navigation) {
                 return null;
             }
         }
         if ($options['level'] > 1) {
             $currentPage = $this->pageStack->getCurrentPage();
             $parents = $currentPage->getParents();
             $parents[] = $currentPage;
             $currentLevel = count($parents) + 1;
             $page = $this->arrayLevel($parents, $options['level']);
             if ($page && $page->getId() > 0) {
                 $navigation = $this->pageStack->getPage($page->getId());
             } elseif ($options['level'] == $currentLevel + 1) {
                 $navigation = $this->pageStack->getCurrentPage();
             }
         }
         if ($options['level'] == 1) {
             $navigation = NodeQuery::create()->findRoot($this->pageStack->getCurrentDomain()->getId());
         }
     }
     return $navigation;
 }
Пример #2
0
 public function breadcrumb(\Twig_Environment $twig, $view = 'JarvesBundle:Default:breadcrumb.html.twig')
 {
     $breadcrumbs = [];
     $page = $this->pageStack->getCurrentPage();
     $cacheKey = 'core/breadcrumbs/' . $page->getCacheKey();
     if ($cache = $this->cacher->getDistributedCache($cacheKey)) {
         if (is_string($cache)) {
             return $cache;
         }
     }
     foreach ($page->getParents() as $parent) {
         if ($parent->getLevel() === 0) {
             continue;
         }
         if ($parent->getType() >= 2) {
             continue;
         }
         $breadcrumbs[] = $parent;
     }
     $data = ['domain' => $this->pageStack->getCurrentDomain(), 'baseUrl' => $this->pageStack->getPageResponse()->getBaseHref(), 'breadcrumbs' => $breadcrumbs, 'currentPage' => $this->pageStack->getCurrentPage()];
     $html = $twig->render($view, $data);
     $this->cacher->setDistributedCache($cacheKey, $html);
     return $html;
 }
Пример #3
0
 /**
  * Returns the id of given path-info. Null if not existent.
  *
  * @return Node|null
  */
 public function searchPage()
 {
     $url = $this->getRequest()->getPathInfo();
     $page = null;
     $title = sprintf('Searching Page [%s]', $url);
     $this->stopwatch->start($title);
     if (!$page) {
         $domain = $this->pageStack->getCurrentDomain();
         $urls = $this->pageStack->getCachedUrlToPage($domain->getId());
         $possibleUrl = $url;
         $id = false;
         while (1) {
             if (isset($urls[$possibleUrl])) {
                 $id = $urls[$possibleUrl];
                 break;
             }
             if (false !== ($pos = strrpos($possibleUrl, '/'))) {
                 $possibleUrl = substr($possibleUrl, 0, $pos);
             } else {
                 break;
             }
         }
         if (!$id) {
             //set to startpage
             $id = $domain->getStartnodeId();
             $possibleUrl = '/';
         }
         $url = $possibleUrl;
         if ($url == '/') {
             $pageId = $this->pageStack->getCurrentDomain()->getStartnodeId();
             if (!$pageId > 0) {
                 $this->eventDispatcher->dispatch('core/domain-no-start-page');
             }
         } else {
             $pageId = $id;
         }
         /** @var \Jarves\Model\Node $page */
         $page = $this->pageStack->getPage($pageId);
     }
     $this->stopwatch->stop($title);
     return $page;
 }
Пример #4
0
 /**
  * Gets the html title.
  *
  * @return string
  */
 public function getTitle()
 {
     if (null !== $this->title) {
         return $this->title;
     }
     if ($this->getDomainHandling() && $this->pageStack->getCurrentDomain()) {
         $title = $this->pageStack->getCurrentDomain()->getTitleFormat() ?: '%title%';
         if ($page = $this->pageStack->getCurrentPage()) {
             return str_replace(array('%title%'), array($page->getAlternativeTitle() ?: $page->getTitle()), $title);
         }
     } else {
         if ($this->pageStack->getCurrentPage()) {
             return $this->pageStack->getCurrentPage()->getTitle();
         }
     }
 }