public function TableFormatter::viewElements

Implements \Drupal\field\Plugin\Type\Formatter\FormatterInterface::viewElements().

Overrides FormatterInterface::viewElements

File

drupal/core/modules/file/lib/Drupal/file/Plugin/field/formatter/TableFormatter.php, line 32
Contains \Drupal\file\Plugin\field\formatter\TableFormatter.

Class

TableFormatter
Plugin implementation of the 'file_table' formatter.

Namespace

Drupal\file\Plugin\field\formatter

Code

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;
}