You are here

public function SlickTextFormatter::buildElements in Slick Carousel 8.2

Same name and namespace in other branches
  1. 7.3 src/Plugin/Field/FieldFormatter/SlickTextFormatter.php \Drupal\slick\Plugin\Field\FieldFormatter\SlickTextFormatter::buildElements()

Build the slick carousel elements.

File

src/Plugin/Field/FieldFormatter/SlickTextFormatter.php, line 66

Class

SlickTextFormatter
Plugin implementation of the 'Slick Text' formatter.

Namespace

Drupal\slick\Plugin\Field\FieldFormatter

Code

public function buildElements(array &$build, $items) {

  // The ProcessedText element already handles cache context & tag bubbling.
  // @see \Drupal\filter\Element\ProcessedText::preRenderText()
  foreach ($items as $key => $item) {
    if (empty($item->value)) {
      continue;
    }
    $element = [
      '#type' => 'processed_text',
      '#text' => $item->value,
      '#format' => $item->format,
      '#langcode' => $item
        ->getLangcode(),
    ];
    $build['items'][$key] = $element;
    unset($element);
  }
}