/** * Groups are inside the same repository as the pages * @return string */ public function getNestedSetRepositoryClassName() { return Abstraction\AbstractPage::CN(); }
public function addFilterByChild(AbstractPage $page, $minDepth = 0, $maxDepth = null) { $level = $page->getLevel(); if ($minDepth < 0) { $minDepth = $level + $minDepth; } if ($maxDepth < 0) { $maxDepth = $level + $maxDepth; } $this->addLevelFilter($minDepth, is_null($maxDepth) ? null : $maxDepth); $leftLimit = $page->getLeftValue(); $rightLimit = $page->getRightValue(); $this->getSearchCondition()->leftLessThanOrEqualsTo($leftLimit); $this->getSearchCondition()->rightGreaterThanOrEqualsTo($rightLimit); }
/** * Constructor */ public function __construct() { parent::__construct(); $this->templateLayouts = new ArrayCollection(); }
/** * @param AbstractPage $page * @param string $locale * @return array */ protected function convertPageToArray(AbstractPage $page, $locale) { /* @var $localization Entity\Abstraction\Localization */ $localization = null; // Must have group localization with ID equal with master because group localizations are not published currently if ($page instanceof GroupPage) { $localization = $page->createLocalization($locale); } else { $localization = $page->getLocalization($locale); } $array = array(); $localizationExists = true; if (empty($localization)) { $localeManager = $this->container->getLocaleManager(); $localizationExists = false; // try to get any localization if page is not localized and is global if ($page->isGlobal() || !$page->isGlobal() && $page->isRoot()) { // TODO: temporary (and ugly also) workaround to fetch oldest localization from all available // this, i suppose, will be replaced with dialog window with localization selector $localizations = $page->getLocalizations(); $localization = $localizations->first(); // Search for the first created localization by it's ID foreach ($localizations as $_localization) { /* @var $_localization Entity\Abstraction\Localization */ if (strcmp($_localization->getId(), $localization->getId()) < 0) { $localeId = $_localization->getLocaleId(); if ($localeManager->hasLocale($localeId)) { $localization = $_localization; } } } // collecting available localizations foreach ($localizations as $_localization) { $localeId = $_localization->getLocaleId(); if ($localeManager->hasLocale($localeId)) { $data = array('title' => $_localization->getTitle()); if ($_localization instanceof PageLocalization) { $data['path'] = $_localization->getPathPart(); } $array['localizations'][$_localization->getLocaleId()] = $data; } } } else { //FIXME: maybe need to throw exception here? return null; } } $nodeData = null; if ($localization instanceof Localization) { $nodeData = $this->loadNodeMainData($localization, $localizationExists); } if (!empty($nodeData)) { $array = array_merge($nodeData, $array); } if ($page instanceof Entity\Template) { $array['type'] = 'template'; } return $array; }
/** * @param AbstractPage $source * @return AbstractPage */ public function copyAbstractPage(AbstractPage $source) { $deepCopy = new DeepCopy(); $entityManager = $this->container->getDoctrine()->getManagerForClass(get_class($source)); $deepCopy->addFilter(new KeepFilter(), new PropertyMatcher(AbstractPage::CN(), 'nestedSetNode')); $this->addDeepCopyCommonFilters($deepCopy, $entityManager); $copiedPage = $deepCopy->copy($source); $entityManager->persist($copiedPage); return $copiedPage; }