public function FFTFormatter::viewElements in Field Formatter Template 8
Same name and namespace in other branches
- 8.2 src/Plugin/Field/FieldFormatter/FFTFormatter.php \Drupal\fft\Plugin\Field\FieldFormatter\FFTFormatter::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 FormatterInterface::viewElements
File
- src/Plugin/ Field/ FieldFormatter/ FFTFormatter.php, line 172 
Class
- FFTFormatter
- Plugin implementation of the 'fft_formatter' formatter.
Namespace
Drupal\fft\Plugin\Field\FieldFormatterCode
public function viewElements(FieldItemListInterface $items, $langcode) {
  $entity = $items
    ->getEntity();
  $field_type = $this->fieldDefinition
    ->getType();
  $settings = $this
    ->getSettings();
  $data_items = $items;
  if ($this
    ->isReference($field_type)) {
    $data_items = $this
      ->getEntitiesToView($items, $langcode);
  }
  $elements = fft_field_formatter_render($entity, $field_type, $data_items, $settings, $langcode);
  return $elements;
}