Plugin implementation of the 'file_table' formatter.
@FieldFormatter(
id = "file_table",
module = "file",
label = @Translation("Table of files"),
field_types = {
"file"
}
)
Expanded class hierarchy of TableFormatter
class TableFormatter extends FormatterBase {
/**
* Implements \Drupal\field\Plugin\Type\Formatter\FormatterInterface::viewElements().
*/
public function viewElements(EntityInterface $entity, $langcode, array $items) {
$elements = array();
if (!empty($items)) {
// Display all values in a single element.
$elements[0] = array(
'#theme' => 'file_formatter_table',
'#items' => $items,
);
}
return $elements;
}
}