You are here

public function EmptyFieldText::react in Empty fields 8

Builds render array for empty field.

Renderable array to display.

Parameters

array $context: An associative array containing:

  • entity: The entity being rendered.
  • view_mode: The view mode; for example, 'full' or 'teaser'.
  • display: The EntityDisplay holding the display options.

Overrides EmptyFieldPluginBase::react

File

src/Plugin/EmptyFields/EmptyFieldText.php, line 21

Class

EmptyFieldText
Defines EmptyFieldText.

Namespace

Drupal\empty_fields\Plugin\EmptyFields

Code

public function react(array $context) {
  $args = [
    $context['entity']
      ->getEntityTypeId() => $context['entity'],
    'user' => \Drupal::currentUser(),
  ];
  $text = \Drupal::token()
    ->replace($this->configuration['empty_text'], $args, [
    'clear' => TRUE,
  ]);
  return [
    '#markup' => $text,
  ];
}