You are here

protected function Components::viewValue in Dimension 2.1.x

Same name and namespace in other branches
  1. 2.0.x src/Plugin/Field/FieldFormatter/Components.php \Drupal\dimension\Plugin\Field\FieldFormatter\Components::viewValue()

Generate the output appropriate for one field item.

Parameters

\Drupal\Core\Field\FieldItemInterface $item: One field item.

Return value

array The textual output generated as a render array.

Overrides StringFormatter::viewValue

File

src/Plugin/Field/FieldFormatter/Components.php, line 14

Class

Components
Abstract class for length, area and volume formatters.

Namespace

Drupal\dimension\Plugin\Field\FieldFormatter

Code

protected function viewValue(FieldItemInterface $item) {
  $build = [
    '#theme' => $this->pluginId,
  ];
  foreach ($this
    ->fields() as $name => $label) {
    $build['#' . $name] = $item
      ->get($name)
      ->getValue();
  }
  return $build;
}