You are here

public function JCarouselFormatter::viewElements in jCarousel 8.4

Same name and namespace in other branches
  1. 8.5 src/Plugin/Field/FieldFormatter/JCarouselFormatter.php \Drupal\jcarousel\Plugin\Field\FieldFormatter\JCarouselFormatter::viewElements()

Builds a renderable array for a field value.

Parameters

\Drupal\Core\Field\FieldItemListInterface $items: The field values to be rendered.

string $langcode: The language that should be used to render the field.

Return value

array A renderable array for $items, as an array of child elements keyed by consecutive numeric indexes starting from 0.

Overrides ImageFormatter::viewElements

File

src/Plugin/Field/FieldFormatter/JCarouselFormatter.php, line 284
Contains \Drupal\jcarousel\Plugin\Field\FieldFormatter\JCarouselFormatter.

Class

JCarouselFormatter
Plugin implementation of the 'jCarousel' formatter.

Namespace

Drupal\jcarousel\Plugin\Field\FieldFormatter

Code

public function viewElements(FieldItemListInterface $items, $langcode) {
  $jcarousel_items = parent::viewElements($items, $langcode);
  $jcarousel_options = $this
    ->getSettings();
  unset($jcarousel_items['image_link']);
  unset($jcarousel_items['image_style']);
  $elements[] = [
    '#theme' => 'jcarousel',
    '#items' => $jcarousel_items,
    '#options' => $jcarousel_options,
  ];
  return $elements;
}