You are here

public function ViewExecutable::setCurrentPage in Zircon Profile 8

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

Change/Set the current page for the pager.

Parameters

int $page: The current page.

1 call to ViewExecutable::setCurrentPage()
ViewExecutable::unserialize in core/modules/views/src/ViewExecutable.php

File

core/modules/views/src/ViewExecutable.php, line 505
Contains \Drupal\views\ViewExecutable.

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);
  }
}