function ViewExecutable::initPager

Same name in other branches
  1. 9 core/modules/views/src/ViewExecutable.php \Drupal\views\ViewExecutable::initPager()
  2. 8.9.x core/modules/views/src/ViewExecutable.php \Drupal\views\ViewExecutable::initPager()
  3. 11.x core/modules/views/src/ViewExecutable.php \Drupal\views\ViewExecutable::initPager()

Initializes the pager.

Like style initialization, pager initialization is held until late to allow for overrides.

1 call to ViewExecutable::initPager()
ViewExecutable::getPager in core/modules/views/src/ViewExecutable.php
Gets the current pager plugin.

File

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

Class

ViewExecutable
Represents a view as a whole.

Namespace

Drupal\views

Code

public function initPager() {
    if (!isset($this->pager)) {
        $this->pager = $this->display_handler
            ->getPlugin('pager');
        if ($this->usePager()) {
            $this->pager
                ->setCurrentPage($this->current_page);
        }
        // These overrides may have been set earlier via $view->set_*
        // functions.
        if (isset($this->items_per_page)) {
            $this->pager
                ->setItemsPerPage($this->items_per_page);
        }
        if (isset($this->offset)) {
            $this->pager
                ->setOffset($this->offset);
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.