Plugin implementation of the 'file_default' formatter.
@Plugin(
id = "file_default",
module = "file",
label = @Translation("Generic file"),
field_types = {
"file"
}
)
Expanded class hierarchy of GenericFileFormatter
class GenericFileFormatter extends FormatterBase {
/**
* Implements \Drupal\field\Plugin\Type\Formatter\FormatterInterface::viewElements().
*/
public function viewElements(EntityInterface $entity, $langcode, array $items) {
$elements = array();
foreach ($items as $delta => $item) {
$elements[$delta] = array(
'#theme' => 'file_link',
'#file' => (object) $item,
);
}
return $elements;
}
}