QueryBase::pager

public QueryBase::pager($limit = 10, $element = NULL)

Enables a pager for the query.

Parameters

$limit: An integer specifying the number of elements per page. If passed a false value (FALSE, 0, NULL), the pager is disabled.

$element: An optional integer to distinguish between multiple pagers on one page. If not provided, one is automatically calculated.

Return value

\Drupal\Core\Entity\Query\QueryInterface The called object.

Overrides QueryInterface::pager

File

core/lib/Drupal/Core/Entity/Query/QueryBase.php, line 269

Class

QueryBase
The base entity query class.

Namespace

Drupal\Core\Entity\Query

Code

public function pager($limit = 10, $element = NULL) {
  // Even when not using SQL, storing the element PagerSelectExtender is as
  // good as anywhere else.
  if (!isset($element)) {
    $element = PagerSelectExtender::$maxElement++;
  }
  elseif ($element >= PagerSelectExtender::$maxElement) {
    PagerSelectExtender::$maxElement = $element + 1;
  }

  $this->pager = array(
    'limit' => $limit,
    'element' => $element,
  );
  return $this;
}
doc_Drupal
2016-10-29 09:35:43
Comments
Leave a Comment

Please login to continue.