You are here

public function TaskLogItemFormatter::viewElements in General Data Protection Regulation 8

Same name and namespace in other branches
  1. 8.2 modules/gdpr_tasks/src/Plugin/Field/FieldFormatter/TaskLogItemFormatter.php \Drupal\gdpr_tasks\Plugin\Field\FieldFormatter\TaskLogItemFormatter::viewElements()
  2. 3.0.x modules/gdpr_tasks/src/Plugin/Field/FieldFormatter/TaskLogItemFormatter.php \Drupal\gdpr_tasks\Plugin\Field\FieldFormatter\TaskLogItemFormatter::viewElements()

Builds a renderable array for a field value.

Parameters

\Drupal\Core\Field\FieldItemListInterface $items: The field values to be rendered.

string $langcode: The language that should be used to render the field.

Return value

array A renderable array for $items, as an array of child elements keyed by consecutive numeric indexes starting from 0.

Overrides FormatterInterface::viewElements

File

modules/gdpr_tasks/src/Plugin/Field/FieldFormatter/TaskLogItemFormatter.php, line 24

Class

TaskLogItemFormatter
Plugin implementation of the TaskLogItem formatter.

Namespace

Drupal\gdpr_tasks\Plugin\Field\FieldFormatter

Code

public function viewElements(FieldItemListInterface $items, $langcode) {
  $elements = [];
  foreach ($items as $key => $item) {
    $elements[$key] = [
      '#type' => 'markup',
      '#markup' => "Entity type: {$item->entity_type} ID: {$item->entity_id} Field name: {$item->field_name} Action: {$item->action} Anonymizer: {$item->anonymizer}",
    ];
  }
  return $elements;
}