Contains \Drupal\file\Plugin\field\formatter\TableFormatter.
<?php /** * @file * Contains \Drupal\file\Plugin\field\formatter\TableFormatter. */ namespace Drupal\file\Plugin\field\formatter; use Drupal\field\Annotation\FieldFormatter; use Drupal\Core\Annotation\Translation; use Drupal\field\Plugin\Type\Formatter\FormatterBase; use Drupal\Core\Entity\EntityInterface; /** * Plugin implementation of the 'file_table' formatter. * * @FieldFormatter( * id = "file_table", * module = "file", * label = @Translation("Table of files"), * field_types = { * "file" * } * ) */ 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; } }