Jarves\PageStack::getPage PHP Метод

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

Returns a super fast cached Page object.
public getPage ( Node | string | integer $node ) : Node | null
$node Jarves\Model\Node | string | integer Node model, url or node id
Результат Jarves\Model\Node | null
    public function getPage($node)
    {
        $pageId = $node;
        if ($node instanceof Node) {
            return $node;
        }
        if (!is_numeric($node)) {
            $urlsToPage = $this->getCachedUrlToPage($this->getCurrentDomain()->getId());
            if (isset($urlsToPage[$node])) {
                $pageId = $urlsToPage[$node];
            } else {
                return null;
            }
        }
        $data = $this->cacher->getDistributedCache('core/object/node/' . $pageId);
        if (!$data) {
            $page = NodeQuery::create()->findPk($pageId);
            $this->cacher->setDistributedCache('core/object/node/' . $pageId, serialize($page));
        } else {
            $page = unserialize($data);
        }
        return $page ?: null;
    }

Usage Example

Пример #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;
 }
All Usage Examples Of Jarves\PageStack::getPage