本文整理汇总了PHP中Localization::getMaster方法的典型用法代码示例。如果您正苦于以下问题:PHP Localization::getMaster方法的具体用法?PHP Localization::getMaster怎么用?PHP Localization::getMaster使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Localization
的用法示例。
在下文中一共展示了Localization::getMaster方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: gatherChildrenData
/**
* Returns children page array data
* @param string $entity
* @param Localization $parentLocalization
* @param string $filter
* @param integer $levels
* @param boolean $count
* @return mixed
*/
private function gatherChildrenData($entity, $parentLocalization, $filter = null, $levels = null, $count = false)
{
$input = $this->getRequestInput();
$localeId = $this->getCurrentLocale()->getId();
// @TODO: existing_only flag is used for LinkManager, when it requests for available pages for linking.
// should split that onto two separate methods.
$existingOnly = $input->filter('existing_only', false, false, FILTER_VALIDATE_BOOLEAN);
$customTitleQuery = $input->get('query', false);
$entityManager = $this->getEntityManager();
$pageFinder = $entity === Page::CN() ? new PageFinder($entityManager) : new TemplateFinder($entityManager);
// Reading by one level because need specific reading strategy for application pages
if (empty($parentLocalization)) {
$pageFinder->addLevelFilter(0, 0);
} else {
$rootNode = $parentLocalization->getMaster();
$pageFinder->addFilterByParent($rootNode, 1, 1);
}
$queryBuilder = $pageFinder->getQueryBuilder();
if ($existingOnly) {
$queryBuilder->leftJoin('e.localizations', 'l_', 'WITH', 'l_.locale = :locale')->setParameter('locale', $localeId)->leftJoin('e.localizations', 'l')->andWhere('l_.id IS NOT NULL OR e INSTANCE OF ' . GroupPage::CN());
} else {
$queryBuilder->leftJoin('e.localizations', 'l_', 'WITH', 'l_.locale = :locale')->setParameter('locale', $localeId)->leftJoin('e.localizations', 'l')->andWhere('l_.id IS NOT NULL OR e.global = true OR (e.level = 0 AND e.global = false)');
}
if ($customTitleQuery) {
$queryBuilder->andWhere('l_.title LIKE :customTitleQuery');
$queryBuilder->setParameter('customTitleQuery', $customTitleQuery . '%');
}
$filterFolders = array();
$application = null;
if ($parentLocalization instanceof ApplicationLocalization) {
// This is bad solution for detecting where the sitemap has been requested from.
// Should group by month if sitemap requested in the sidebar.
//FIXME: JS should pass preference maybe
if (empty($filter) && $existingOnly) {
$filter = 'group';
}
$application = $this->getPageApplicationManager()->createApplicationFor($parentLocalization, $this->getEntityManager());
$filterFolders = $application->getFilterFolders($queryBuilder, $filter);
$application->applyFilters($queryBuilder, $filter);
}
$query = $queryBuilder->getQuery();
if ($input->has('offset')) {
$offset = $input->getInt('offset');
$query->setFirstResult($offset);
}
if ($input->has('resultsPerRequest')) {
$limit = $input->getInt('resultsPerRequest');
$query->setMaxResults($limit);
}
$paginator = new \Doctrine\ORM\Tools\Pagination\Paginator($query, true);
// TODO: fix, shouldn't return mixed result depending on arguments
if ($count) {
// When only the count is needed...
$count = count($filterFolders) + count($paginator);
return $count;
} else {
$response = array();
// Prepend the filter folders
$pages = array_merge($filterFolders, iterator_to_array($paginator));
if (!is_null($levels)) {
$levels--;
}
foreach ($filterFolders as $filterFolder) {
if (!$filterFolder instanceof TemporaryGroupPage) {
throw new \LogicException("Application " . get_class($application) . ' returned invalid filter folders');
}
}
foreach ($pages as $page) {
$pageData = $this->convertPageToArray($page, $localeId);
// Skipping the page
if (is_null($pageData)) {
continue;
}
$pageData['children_count'] = 0;
$localization = $page->getLocalization($localeId);
if (!empty($localization)) {
$filter = null;
if ($page instanceof TemporaryGroupPage) {
$filter = $page->getTitle();
$localization = $parentLocalization;
// TODO: for now it's enabled for all filter folders
$pageData['childrenListStyle'] = 'scrollList';
$pageData['selectable'] = false;
$pageData['editable'] = false;
$pageData['isDraggable'] = false;
$pageData['isDropTarget'] = true;
$pageData['new_children_first'] = true;
}
if ($levels === 0 && $page instanceof TemporaryGroupPage && $page->hasCalculatedNumberChildren()) {
$pageData['children_count'] = $page->getNumberChildren();
} elseif ($levels === 0) {
//.........这里部分代码省略.........