You are here

public function MessageAction::execute in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Action/Plugin/Action/MessageAction.php \Drupal\Core\Action\Plugin\Action\MessageAction::execute()

Executes the plugin.

Overrides ExecutableInterface::execute

File

core/lib/Drupal/Core/Action/Plugin/Action/MessageAction.php, line 81

Class

MessageAction
Sends a message to the current user's screen.

Namespace

Drupal\Core\Action\Plugin\Action

Code

public function execute($entity = NULL) {
  if (empty($this->configuration['node'])) {
    $this->configuration['node'] = $entity;
  }
  $message = $this->token
    ->replace($this->configuration['message'], $this->configuration);
  $build = [
    '#markup' => $message,
  ];

  // @todo Fix in https://www.drupal.org/node/2577827
  $this->messenger
    ->addStatus($this->renderer
    ->renderPlain($build));
}