protected function FilemimeFormatter::viewValue in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/file/src/Plugin/Field/FieldFormatter/FilemimeFormatter.php \Drupal\file\Plugin\Field\FieldFormatter\FilemimeFormatter::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/ FilemimeFormatter.php, line 64 - Contains \Drupal\file\Plugin\Field\FieldFormatter\FilemimeFormatter.
Class
- FilemimeFormatter
- Formatter to render the file mime type, with an optional icon.
Namespace
Drupal\file\Plugin\Field\FieldFormatterCode
protected function viewValue(FieldItemInterface $item) {
$value = $item->value;
if ($this
->getSetting('filemime_image') && $value) {
$file_icon = [
'#theme' => 'image__file_icon',
'#file' => $item
->getEntity(),
];
return $file_icon;
}
return $value;
}