/** * {@inheritdoc} */ protected function getPageBy(SiteInterface $site = null, $fieldName, $value) { if ('id' == $fieldName) { $fieldName = 'pageId'; $id = $value; } elseif (isset($this->pageReferences[$fieldName][$value])) { $id = $this->pageReferences[$fieldName][$value]; } else { $id = null; } if (null === $id || !isset($this->pages[$id])) { $parameters = array($fieldName => $value); if ($site) { $parameters['site'] = $site->getId(); } $snapshot = $this->snapshotManager->findEnableSnapshot($parameters); if (!$snapshot) { throw new PageNotFoundException(); } $page = new SnapshotPageProxy($this->snapshotManager, $this->transformer, $snapshot); $this->pages[$id] = false; if ($page) { $this->loadBlocks($page); $id = $page->getId(); if ($fieldName != 'id') { $this->pageReferences[$fieldName][$value] = $id; } $this->pages[$id] = $page; } } return $this->pages[$id]; }
/** * {@inheritdoc} */ public function getParents() { if (!$this->parents) { $parents = array(); $snapshot = $this->snapshot; while ($snapshot) { $content = $snapshot->getContent(); if (!$content['parent_id']) { break; } $snapshot = $this->manager->findEnableSnapshot(array('pageId' => $content['parent_id'])); if (!$snapshot) { break; } $parents[] = new SnapshotPageProxy($this->manager, $this->transformer, $snapshot); } $this->setParents(array_reverse($parents)); } return $this->parents; }