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


PHP Pagerfanta::setNormalizeOutOfRangePages方法代码示例

本文整理汇总了PHP中Pagerfanta\Pagerfanta::setNormalizeOutOfRangePages方法的典型用法代码示例。如果您正苦于以下问题:PHP Pagerfanta::setNormalizeOutOfRangePages方法的具体用法?PHP Pagerfanta::setNormalizeOutOfRangePages怎么用?PHP Pagerfanta::setNormalizeOutOfRangePages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pagerfanta\Pagerfanta的用法示例。


在下文中一共展示了Pagerfanta::setNormalizeOutOfRangePages方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getPagerfanta

 /**
  * @return Pagerfanta
  */
 public function getPagerfanta()
 {
     if (is_null($this->pagerfanta)) {
         $adapter = new DoctrineORMAdapter($this->getQuery());
         $this->pagerfanta = new Pagerfanta($adapter);
         $this->pagerfanta->setNormalizeOutOfRangePages(true);
         $this->pagerfanta->setMaxPerPage($this->getLimit());
         $this->pagerfanta->setCurrentPage($this->getPage());
     }
     return $this->pagerfanta;
 }
开发者ID:VickyDeschrijver,项目名称:KunstmaanBundlesCMS,代码行数:14,代码来源:AbstractDoctrineORMAdminListConfigurator.php

示例2: getData

 /**
  * {@inheritdoc}
  */
 public function getData(Parameters $parameters)
 {
     // Use output walkers option in DoctrineORMAdapter should be false as it affects performance greatly. (see #3775)
     $paginator = new Pagerfanta(new DoctrineORMAdapter($this->queryBuilder, true, false));
     $paginator->setNormalizeOutOfRangePages(true);
     $paginator->setCurrentPage($parameters->get('page', 1));
     return $paginator;
 }
开发者ID:loic425,项目名称:Sylius,代码行数:11,代码来源:DataSource.php

示例3: testSetCurrentPageShouldNormalizePageWhenOutOfRangePageAndIndicatingNormalizeOutOfRangePages

 public function testSetCurrentPageShouldNormalizePageWhenOutOfRangePageAndIndicatingNormalizeOutOfRangePages()
 {
     $this->setAdapterNbResultsAny(100);
     $this->pagerfanta->setMaxPerPage(10);
     $this->pagerfanta->setAllowOutOfRangePages(false);
     $this->pagerfanta->setNormalizeOutOfRangePages(true);
     $this->pagerfanta->setCurrentPage(11);
     $this->assertSame(10, $this->pagerfanta->getCurrentPage());
 }
开发者ID:3lolo,项目名称:lr_app,代码行数:9,代码来源:PagerfantaTest.php

示例4: getData

 /**
  * {@inheritdoc}
  */
 public function getData(Parameters $parameters)
 {
     $countQueryBuilderModifier = function ($queryBuilder) {
         $queryBuilder->select('COUNT(DISTINCT o.id) AS total_results')->setMaxResults(1);
     };
     $paginator = new Pagerfanta(new DoctrineDbalAdapter($this->queryBuilder, $countQueryBuilderModifier));
     $paginator->setNormalizeOutOfRangePages(true);
     $paginator->setCurrentPage($parameters->get('page', 1));
     return $paginator;
 }
开发者ID:sylius,项目名称:sylius,代码行数:13,代码来源:DataSource.php

示例5: injectPager

 /**
  * Injects the pager with related content into the view.
  *
  * @param \eZ\Publish\Core\MVC\Symfony\View\Event\FilterViewParametersEvent $event
  */
 public function injectPager(FilterViewParametersEvent $event)
 {
     $view = $event->getView();
     if (!$view instanceof TagView) {
         return;
     }
     if ($this->adapter instanceof TagAdapterInterface) {
         $this->adapter->setTag($view->getTag());
     }
     $pager = new Pagerfanta($this->adapter);
     $pager->setNormalizeOutOfRangePages(true);
     $builderParameters = $event->getBuilderParameters();
     $pager->setMaxPerPage($this->pagerLimit > 0 ? $this->pagerLimit : 10);
     $pager->setCurrentPage($builderParameters['page'] > 0 ? $builderParameters['page'] : 1);
     $event->getParameterBag()->set('related_content', $pager);
 }
开发者ID:netgen,项目名称:tagsbundle,代码行数:21,代码来源:RelatedContentPager.php

示例6: serializePagerfanta

 /**
  * @param JsonApiSerializationVisitor $visitor
  * @param Pagerfanta                  $pagerfanta
  * @param array                       $type
  * @param Context                     $context
  * @return Pagerfanta
  */
 public function serializePagerfanta(JsonApiSerializationVisitor $visitor, Pagerfanta $pagerfanta, array $type, Context $context)
 {
     $request = $this->requestStack->getCurrentRequest();
     $pagerfanta->setNormalizeOutOfRangePages(true);
     $pagerfanta->setAllowOutOfRangePages(true);
     $pagerfanta->setMaxPerPage($request->get('page[limit]', $this->paginationOptions['limit'], true));
     $pagerfanta->setCurrentPage($request->get('page[number]', 1, true));
     $results = $pagerfanta->getCurrentPageResults();
     if ($results instanceof \ArrayIterator) {
         $results = $results->getArrayCopy();
     }
     $data = $context->accept($results);
     $root = $visitor->getRoot();
     $root['meta'] = array('page' => $pagerfanta->getCurrentPage(), 'limit' => $pagerfanta->getMaxPerPage(), 'pages' => $pagerfanta->getNbPages(), 'total' => $pagerfanta->getNbResults());
     $root['links'] = array('first' => $this->getUriForPage(1), 'last' => $this->getUriForPage($pagerfanta->getNbPages()), 'prev' => $pagerfanta->hasPreviousPage() ? $this->getUriForPage($pagerfanta->getPreviousPage()) : null, 'next' => $pagerfanta->hasNextPage() ? $this->getUriForPage($pagerfanta->getNextPage()) : null);
     $visitor->setRoot($root);
     return $data;
 }
开发者ID:aliebing,项目名称:JsonApiBundle,代码行数:25,代码来源:PagerfantaHandler.php

示例7: createView

 /**
  * Creates and returns the table view.
  *
  * @param Request $request
  * @throws RuntimeException
  * @return TableView
  */
 public function createView(Request $request = null)
 {
     if (null !== $request) {
         $this->requestHelper->setRequest($request);
     }
     $view = new TableView();
     $view->name = $this->getName();
     $view->options = ['selector' => $this->config->getSelector()];
     $view->selection_form = $this->config->getSelector();
     if (!$this->config->hasColumns()) {
         throw new RuntimeException('Table has no columns and cannot be generated.');
     }
     $class = $this->config->getDataClass();
     $alias = strtolower(substr($class, strrpos($class, '\\') + 1, 1));
     // TODO What if data is already set ?
     $queryBuilder = $this->entityManager->createQueryBuilder()->select($alias)->from($this->config->getDataClass(), $alias);
     if (null !== ($customizeQb = $this->config->getCustomizeQb())) {
         $customizeQb($queryBuilder, $alias);
     }
     $this->generateFilters($queryBuilder, $view);
     $this->generateColumns($queryBuilder, $view);
     $currentPage = $this->requestHelper->getVar($this->getName() . '_page', 1);
     /*$dql = $queryBuilder->getQuery()->getDQL();
       var_dump($dql);
       exit();*/
     $adapter = new DoctrineORMAdapter($queryBuilder);
     $pager = new Pagerfanta($adapter);
     $pager->setNormalizeOutOfRangePages(true)->setMaxPerPage($this->config->getMaxPerPage())->setCurrentPage($currentPage);
     $this->setData($pager->getCurrentPageResults());
     if ($currentPage != $pager->getCurrentPage()) {
         $this->requestHelper->setVar($this->getName() . '_page', $pager->getCurrentPage());
     }
     $view->pager = $pager;
     $this->generateCells($view);
     return $view;
 }
开发者ID:ekyna,项目名称:table,代码行数:43,代码来源:Table.php


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