You are here

protected function Progressive::buildPageList in Pagerer 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/pagerer/Progressive.php \Drupal\pagerer\Plugin\pagerer\Progressive::buildPageList()

Return an array of pages.

Return value

array render array of pages items.

Overrides Standard::buildPageList

File

src/Plugin/pagerer/Progressive.php, line 72

Class

Progressive
Pager style with links to pages progressively more distant from current.

Namespace

Drupal\pagerer\Plugin\pagerer

Code

protected function buildPageList() {
  $current = $this->pager
    ->getCurrentPage();
  $last = $this->pager
    ->getLastPage();

  // First.
  $pages[0] = $this
    ->getPageItem(-$current, 'absolute', FALSE, $current == 0 ? 'page_current' : 'page');

  // Last.
  $pages[$last] = $this
    ->getPageItem($last - $current, 'absolute', FALSE, $current == $last ? 'page_current' : 'page');

  // Neighborhood.
  $pages = $this
    ->buildNeighborhoodPageList($pages);

  // Progressive.
  if ($this
    ->getOption('factors')) {
    $factors = explode(',', $this
      ->getOption('factors'));
    foreach ($factors as $scale_factor) {
      $pages = $this
        ->buildProgressivePageList($pages, $scale_factor, 10);
    }
  }
  ksort($pages);
  return $pages;
}