当前位置: 首页>>代码示例>>PHP>>正文


PHP Localization::getMaster方法代码示例

本文整理汇总了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) {
//.........这里部分代码省略.........
开发者ID:sitesupra,项目名称:sitesupra,代码行数:101,代码来源:PagesSitemapController.php


注:本文中的Localization::getMaster方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。