本文整理汇总了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;
}
示例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());
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}