You are here

protected function Slider::buildPagerItems in Pagerer 8

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

Return the pager render array.

Return value

array render array.

File

src/Plugin/pagerer/Slider.php, line 86

Class

Slider
Pager style using a jQuery slider.

Namespace

Drupal\pagerer\Plugin\pagerer

Code

protected function buildPagerItems() {

  // Prepares state.
  $state_settings = [
    'action' => $this
      ->getOption('slider_action'),
    'timeout' => $this
      ->getOption('slider_action_timeout'),
    'icons' => $this
      ->getOption('slider_navigation_icons'),
    'tickmarkTitle' => $this
      ->getDisplayTag('slider_tickmark_title'),
  ];
  if ($slider_width = $this
    ->getOption('slider_width')) {
    $state_settings['sliderWidth'] = $slider_width;
  }
  $pagerer_widget_id = $this
    ->prepareJsState($state_settings);

  // Add pager items.
  $items = [];
  if ($this
    ->getOption('slider_navigation_icons') != 'no') {
    $items[] = [
      'widget' => [
        '#theme' => 'pagerer_slider_icon',
        '#icon' => 'circle-minus',
      ],
    ];
  }
  $items[] = [
    'widget' => [
      '#theme' => 'pagerer_slider',
      '#id' => $pagerer_widget_id,
      '#title' => $this
        ->getDisplayTag('slider_title'),
      '#attached' => [
        'drupalSettings' => [
          'pagerer' => [
            'state' => [
              $pagerer_widget_id => $state_settings,
            ],
          ],
        ],
      ],
    ],
  ];
  if ($this
    ->getOption('slider_navigation_icons') != 'no') {
    $items[] = [
      'widget' => [
        '#theme' => 'pagerer_slider_icon',
        '#icon' => 'circle-plus',
      ],
    ];
  }
  return $items;
}