/** {@inheritdoc} */ public function toTwig() { $page = $this->getPageGenerator()->getPage(); $pages = array(); while ($page) { $pages[] = $page->toTwig(); if ($page->getPageId() == $this->rootPageId) { break; } $page = Page::getCachedParent($page); } if ($this->direction === self::FROM_ROOT) { $pages = array_reverse($pages); } return array('pages' => $pages); }
/** * Twig callback to get parent page. * * @param \Page $page * @return array|null */ public function twigGetParent(\Page $page) { $parentPage = \Page::getCachedParent($page); if ($parentPage) { return $this->twigGetPage($parentPage); } return null; }