You are here

protected function Barcode::viewValue in Barcodes 8

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

Generate the output appropriate for one field item.

Parameters

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

Return value

string The textual output generated.

1 call to Barcode::viewValue()
Barcode::viewElements in src/Plugin/Field/FieldFormatter/Barcode.php
Builds a renderable array for a field value.

File

src/Plugin/Field/FieldFormatter/Barcode.php, line 228

Class

Barcode
Plugin implementation of the 'barcode' formatter.

Namespace

Drupal\barcodes\Plugin\Field\FieldFormatter

Code

protected function viewValue(FieldItemInterface $item) {
  if ($item
    ->mainPropertyName()) {
    $value = $item
      ->__get($item
      ->mainPropertyName());
  }
  else {
    $value = $item
      ->getValue();
  }
  return $value;
}