You are here

public function RadioactivityReferenceEmitter::view in Radioactivity 4.0.x

Overrides EntityReferenceFormatterBase::view

See also

::prepareView()

::getEntitiesToView()

File

src/Plugin/Field/FieldFormatter/RadioactivityReferenceEmitter.php, line 110

Class

RadioactivityReferenceEmitter
Plugin implementation of the 'radioactivity_reference_emitter' formatter.

Namespace

Drupal\radioactivity\Plugin\Field\FieldFormatter

Code

public function view(FieldItemListInterface $items, $langcode = NULL) {
  $build = parent::view($items, $langcode);

  // If 'none' is chosen (No value - only emit), we do not want this formatter
  // to be rendered as field (it would be rendered in an empty wrapper div).
  // We only use the children which contain the energy emitter.
  if ($this
    ->getSetting('display') === 'none') {
    $children = Element::children($build);
    $build = array_intersect_key($build, $children);
  }
  return $build;
}