You are here

Components.php in Dimension 2.0.x

Same filename and directory in other branches
  1. 2.1.x src/Plugin/Field/FieldFormatter/Components.php

File

src/Plugin/Field/FieldFormatter/Components.php
View source
<?php

namespace Drupal\dimension\Plugin\Field\FieldFormatter;

use Drupal\Core\Field\FieldItemInterface;
use Drupal\Core\Field\Plugin\Field\FieldFormatter\StringFormatter;
use Drupal\dimension\Plugin\Field\Basic;

/**
 * Abstract class for length, area and volume formatters.
 */
abstract class Components extends StringFormatter implements Basic {
  protected function viewValue(FieldItemInterface $item) {
    $build = [
      '#theme' => $this->pluginId,
    ];
    foreach ($this
      ->fields() as $name => $label) {
      $build['#' . $name] = $item
        ->get($name)
        ->getValue();
    }
    return $build;
  }

}

Classes

Namesort descending Description
Components Abstract class for length, area and volume formatters.