public function LegacyFormatter::viewElements

Implements Drupal\field\Plugin\Type\Formatter\FormatterInterface::viewElements().

Overrides FormatterInterface::viewElements

File

drupal/core/modules/field/lib/Drupal/field/Plugin/field/formatter/LegacyFormatter.php, line 106
Definition of Drupal\field\Plugin\field\formatter\LegacyFormatter.

Class

LegacyFormatter
Plugin implementation for legacy formatters.

Namespace

Drupal\field\Plugin\field\formatter

Code

public function viewElements(EntityInterface $entity, $langcode, array $items) {
  $definition = $this
    ->getDefinition();
  $function = $definition['module'] . '_field_formatter_view';
  if (function_exists($function)) {

    // hook_field_formatter_view() received an array of display properties,
    $display = array(
      'type' => $this
        ->getPluginId(),
      'settings' => $this
        ->getSettings(),
      'weight' => $this->weight,
      'label' => $this->label,
    );
    return $function($entity
      ->entityType(), $entity, $this->field, $this->instance, $langcode, $items, $display);
  }
}