You are here

public function ViewExecutable::setCurrentPage in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/views/src/ViewExecutable.php \Drupal\views\ViewExecutable::setCurrentPage()

Sets the current page for the pager.

Parameters

int $page: The current page.

1 call to ViewExecutable::setCurrentPage()
ViewExecutable::__wakeup in core/modules/views/src/ViewExecutable.php
Magic method implementation to unserialize the view executable.

File

core/modules/views/src/ViewExecutable.php, line 520

Class

ViewExecutable
Represents a view as a whole.

Namespace

Drupal\views

Code

public function setCurrentPage($page) {
  $this->current_page = $page;

  // Calls like ::unserialize() might call this method without a proper $page.
  // Also check whether the element is pre rendered. At that point, the cache
  // keys cannot longer be manipulated.
  if ($page !== NULL && empty($this->element['#pre_rendered'])) {
    $this->element['#cache']['keys'][] = 'page:' . $page;
  }

  // If the pager is already initialized, pass it through to the pager.
  if (!empty($this->pager)) {
    return $this->pager
      ->setCurrentPage($page);
  }
}