You are here

protected function FileUriFormatter::viewValue in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/file/src/Plugin/Field/FieldFormatter/FileUriFormatter.php \Drupal\file\Plugin\Field\FieldFormatter\FileUriFormatter::viewValue()

Generate the output appropriate for one field item.

Parameters

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

Return value

mixed The textual output generated.

Overrides BaseFieldFileFormatterBase::viewValue

File

core/modules/file/src/Plugin/Field/FieldFormatter/FileUriFormatter.php, line 55
Contains \Drupal\file\Plugin\Field\FieldFormatter\FileUriFormatter.

Class

FileUriFormatter
Formatter to render the file URI to its download path.

Namespace

Drupal\file\Plugin\Field\FieldFormatter

Code

protected function viewValue(FieldItemInterface $item) {
  $value = $item->value;
  if ($this
    ->getSetting('file_download_path')) {
    $value = file_create_url($value);
  }
  return $value;
}