You are here

protected function Scrollpane::buildPagerItems in Pagerer 8

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

Return the pager render array.

Return value

array render array.

1 call to Scrollpane::buildPagerItems()
Scrollpane::buildEmptyPager in src/Plugin/pagerer/Scrollpane.php
Render a 'no pages to display' text.

File

src/Plugin/pagerer/Scrollpane.php, line 36

Class

Scrollpane
Pager style to display a scrollpane embedding a full pager.

Namespace

Drupal\pagerer\Plugin\pagerer

Code

protected function buildPagerItems() {

  // Prepares state.
  $state_settings = [
    'quantity' => $this
      ->getOption('quantity'),
    'pageTag' => [
      'page_title' => $this
        ->getTag($this
        ->getOption('display') . '.page_title'),
      'first_title' => $this
        ->getTag($this
        ->getOption('display') . '.first_title'),
      'last_title' => $this
        ->getTag($this
        ->getOption('display') . '.last_title'),
    ],
  ];
  $pagerer_widget_id = $this
    ->prepareJsState($state_settings);
  $items = [];

  // Left buttons.
  $vars = $this
    ->getNavigationItem('first', FALSE);
  $items[] = [
    'widget' => [
      '#theme' => 'pagerer_scrollpane_button',
      '#scope' => 'first',
      '#text' => $vars['text'],
      '#title' => $vars['title'],
    ],
  ];
  $vars = $this
    ->getNavigationItem('previous', FALSE);
  $items[] = [
    'widget' => [
      '#theme' => 'pagerer_scrollpane_button',
      '#scope' => 'previous',
      '#text' => $vars['text'],
      '#title' => $vars['title'],
    ],
  ];

  // Scrollpane.
  $embed_pager_config = NestedArray::mergeDeep($this->configuration, [
    'prefix_display' => FALSE,
    'display_mode' => 'normal',
    'suffix_display' => FALSE,
    'first_link' => 'never',
    'previous_link' => 'never',
    'next_link' => 'never',
    'last_link' => 'never',
    'fl_breakers' => FALSE,
  ]);
  $items[] = [
    'widget' => [
      '#id' => $pagerer_widget_id,
      '#type' => 'pager',
      '#theme' => 'pagerer_base',
      '#style' => 'standard',
      '#element' => $this->pager
        ->getElement(),
      '#parameters' => $this->parameters,
      '#route_name' => $this->pager
        ->getRouteName(),
      '#route_parameters' => $this->pager
        ->getRouteParameters(),
      '#config' => $embed_pager_config,
      '#embedded' => TRUE,
      '#state' => $state_settings,
    ],
  ];

  // Right buttons.
  $vars = $this
    ->getNavigationItem('next', FALSE);
  $items[] = [
    'widget' => [
      '#theme' => 'pagerer_scrollpane_button',
      '#scope' => 'next',
      '#text' => $vars['text'],
      '#title' => $vars['title'],
    ],
  ];
  $vars = $this
    ->getNavigationItem('last', FALSE);
  $items[] = [
    'widget' => [
      '#theme' => 'pagerer_scrollpane_button',
      '#scope' => 'last',
      '#text' => $vars['text'],
      '#title' => $vars['title'],
    ],
  ];
  return $items;
}