public static function getPages(PageRepositoryInterface $pageRepository, $withNoneOption = true) { $result = array(); if ($withNoneOption) { $result["none"] = " "; } $pages = $pageRepository->activePages(); foreach ($pages as $page) { $result[$page->getId()] = $page->getPageName(); } return $result; }
private function initPages($languages) { $pages = $this->pageRepository->activePages(); // Cycles all the website's languages foreach ($languages as $language) { // Cycles all the website's pages foreach ($pages as $page) { $this->pages['page'][] = $this->initPageTree($language, $page); } } }
/** * Overrides the base method to replace the permalink when it is used instad * of the page name * * @param Request $request */ protected function dispatchCurrentPageEvent(Request $request) { $pageName = $request->get('page'); $seo = $this->seoRepository->fromPermalink($pageName); if (null !== $seo) { $page = $this->pageRepository->fromPk($seo->getPageId()); $pageName = $page->getPageName(); } $eventName = sprintf('page_renderer.before_%s_rendering', $pageName); $this->dispatcher->dispatch($eventName, $this->event); }
/** * Saves the current theme structure into a file * * @param ThemeInterface $theme * @param string $themeStructureFile * @throws \Exception */ protected function saveThemeStructure(ThemeInterface $theme, $themeStructureFile) { $templates = array(); foreach ($this->languagesRepository->activeLanguages() as $language) { foreach ($this->pagesRepository->activePages() as $page) { $key = $language->getId() . '-' . $page->getId(); $templates[$key] = $page->getTemplateName(); } } $themeName = $theme->getThemeName(); $currentTheme = array("Theme" => $themeName, "Templates" => $templates); file_put_contents($themeStructureFile, json_encode($currentTheme)); }
/** * Removes the active pages * * @param \RedKiteLabs\RedKiteCms\RedKiteCmsBundle\Core\Repository\Repository\PageRepositoryInterface $pageRepository * @return boolean */ protected function removeActivePages(PageRepositoryInterface $pageRepository) { try { $pages = $pageRepository->activePages(); foreach ($pages as $page) { $page->delete(); } return true; } catch (\Exception $ex) { $this->errorMessage = "An error occoured during the removing of existing pages. The reported error is: " . $ex->getMessage(); return false; } }