You are here

public function InfiniteScroll::render in Views Infinite Scroll 8

Return the renderable array of the pager.

Called during the view render process.

Parameters

$input: Any extra GET parameters that should be retained, such as exposed input.

Overrides PagerPluginBase::render

File

src/Plugin/views/pager/InfiniteScroll.php, line 24

Class

InfiniteScroll
Views pager plugin to handle infinite scrolling.

Namespace

Drupal\views_infinite_scroll\Plugin\views\pager

Code

public function render($input) {
  $this
    ->updatePageInfo();

  // Replace tokens in the button text.
  $text = $this->options['views_infinite_scroll']['button_text'];
  if (!empty($text) && strpos($text, '@') !== FALSE) {
    $replacements = [
      '@next_page_count' => $this
        ->getNumberItemsLeft(),
      '@remaining_items_count' => $this
        ->getRemainingNumberItems(),
      '@total' => (int) $this
        ->getTotalItems(),
    ];
    $this->options['views_infinite_scroll']['button_text'] = strtr($text, $replacements);
  }
  return [
    '#theme' => $this
      ->themeFunctions(),
    '#options' => $this->options['views_infinite_scroll'],
    '#view' => $this->view,
    '#attached' => [
      'library' => [
        'views_infinite_scroll/views-infinite-scroll',
      ],
    ],
    '#element' => $this->options['id'],
    '#parameters' => $input,
  ];
}