/** * Method to override the used page localization * @param PageLocalization $pageLocalization */ public function setPageLocalization(PageLocalization $pageLocalization) { $this->pageLocalization = $pageLocalization; $this->pageId = $pageLocalization->getMaster()->getId(); }
/** * Loads page path * @param PageLocalization $pageData * @return Path */ protected function findPagePath(PageLocalization $pageData) { $active = true; $limited = false; $inSitemap = true; $path = new Path(); // Inactive page children have no path if (!$pageData->isActive()) { $active = false; } if (!$pageData->isVisibleInSitemap()) { $inSitemap = false; } $pathPart = $pageData->getPathPart(); if (is_null($pathPart)) { return array(null, false, false, false); } $path->prependString($pathPart); $page = $pageData->getMaster(); $locale = $pageData->getLocale(); $parentPage = $page->getParent(); if (is_null($parentPage)) { return array($path, $active, $limited, $inSitemap); } $parentLocalization = $parentPage->getLocalization($locale); // No parent page localization if (is_null($parentLocalization)) { return array(null, false, false, false); } // Page application feature to generate base path for pages if ($parentPage instanceof ApplicationPage) { $applicationId = $parentPage->getApplicationId(); $pageApplicationManager = $this->container['cms.pages.page_application_manager']; /* @var $pageApplicationManager PageApplicationManager */ if (!$pageApplicationManager->hasApplication($applicationId)) { throw new Exception\PagePathException(sprintf("Failed to generate path because, page application [%s] not found.", $applicationId), $pageData); } $application = $pageApplicationManager->createApplicationFor($pageData, $this->em); $pathBasePart = $application->generatePath($pageData); $path->prepend($pathBasePart); } // Search nearest page parent while (!$parentLocalization instanceof PageLocalization) { $parentPage = $parentPage->getParent(); if (is_null($parentPage)) { return array($pageData->getPathPart(), $active, $limited, $inSitemap); } $parentLocalization = $parentPage->getLocalization($locale); // No parent page localization if (is_null($parentLocalization)) { return array(null, false, false, false); } } // Is checked further // if ( ! $parentLocalization->isActive()) { // $active = false; // } // Assume that path is already regenerated for the parent $parentPath = $parentLocalization->getPathEntity()->getPath(); $parentActive = $parentLocalization->getPathEntity()->isActive(); $parentInSitemap = $parentLocalization->getPathEntity()->isVisibleInSitemap(); if (!$parentActive) { $active = false; } if (!$parentInSitemap) { $inSitemap = false; } if (is_null($parentPath)) { return array(null, false, false, false); } $path->prepend($parentPath); return array($path, $active, $limited, $inSitemap); }