3 namespace Drupal\file\Plugin\Field\FieldFormatter;
5 use Drupal\Core\Field\FieldItemListInterface;
8 * Plugin implementation of the 'file_table' formatter.
12 * label = @Translation("Table of files"),
18 class TableFormatter extends FileFormatterBase {
23 public function viewElements(FieldItemListInterface $items, $langcode) {
26 if ($files = $this->getEntitiesToView($items, $langcode)) {
27 $header = [t('Attachment'), t('Size')];
29 foreach ($files as $delta => $file) {
33 '#theme' => 'file_link',
36 'tags' => $file->getCacheTags(),
40 ['data' => format_size($file->getSize())],
47 '#theme' => 'table__file_formatter_table',