function FileUriFormatter::viewValue
Same name in other branches
- 9 core/modules/file/src/Plugin/Field/FieldFormatter/FileUriFormatter.php \Drupal\file\Plugin\Field\FieldFormatter\FileUriFormatter::viewValue()
- 10 core/modules/file/src/Plugin/Field/FieldFormatter/FileUriFormatter.php \Drupal\file\Plugin\Field\FieldFormatter\FileUriFormatter::viewValue()
- 11.x core/modules/file/src/Plugin/Field/FieldFormatter/FileUriFormatter.php \Drupal\file\Plugin\Field\FieldFormatter\FileUriFormatter::viewValue()
Overrides BaseFieldFileFormatterBase::viewValue
File
-
core/
modules/ file/ src/ Plugin/ Field/ FieldFormatter/ FileUriFormatter.php, line 51
Class
- FileUriFormatter
- Formatter to render the file URI to its download path.
Namespace
Drupal\file\Plugin\Field\FieldFormatterCode
protected function viewValue(FieldItemInterface $item) {
$value = $item->value;
if ($this->getSetting('file_download_path')) {
// @todo Wrap in file_url_transform_relative(). This is currently
// impossible. See BaseFieldFileFormatterBase::viewElements(). Fix in
// https://www.drupal.org/node/2646744.
$value = file_create_url($value);
}
return $value;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.