public function Base::view in Double Field 4.x
Same name and namespace in other branches
- 8.3 src/Plugin/Field/FieldFormatter/Base.php \Drupal\double_field\Plugin\Field\FieldFormatter\Base::view()
Builds a renderable array for a fully themed field.
Parameters
\Drupal\Core\Field\FieldItemListInterface $items: The field values to be rendered.
string $langcode: (optional) The language that should be used to render the field. Defaults to the current content language.
Return value
array A renderable array for a themed field with its label and all its values.
Overrides FormatterBase::view
File
- src/Plugin/ Field/ FieldFormatter/ Base.php, line 221 
Class
- Base
- Base class for Double field formatters.
Namespace
Drupal\double_field\Plugin\Field\FieldFormatterCode
public function view(FieldItemListInterface $items, $langcode = NULL) : array {
  $elements = [];
  if (count($items) > 0) {
    // A field may appear multiple times in a single view. Since items are
    // passed by reference we need to ensure they are processed only once.
    $items = clone $items;
    $this
      ->prepareItems($items);
    $elements = parent::view($items, $langcode);
  }
  return $elements;
}