當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。