Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Pager.php

function Pager::setCurrentPage

Sets the current page to a valid value within range.

If a page that does not correspond to the actual range of the result set was provided, this function will set the closest page actually within the result set.

Parameters

int $currentPage: (optional) The current page.

1 call to Pager::setCurrentPage()
Pager::__construct in core/lib/Drupal/Core/Pager/Pager.php
Pager constructor.

File

core/lib/Drupal/Core/Pager/Pager.php, line 65

Class

Pager
A value object that represents a pager.

Namespace

Drupal\Core\Pager

Code

protected function setCurrentPage($currentPage = 0) {
    $this->currentPage = max(0, min($currentPage, $this->getTotalPages() - 1));
}
RSS feed
Powered by Drupal