You are here

public function ShowMessage::execute in Business Rules 8

Same name and namespace in other branches
  1. 2.x src/Plugin/BusinessRulesAction/ShowMessage.php \Drupal\business_rules\Plugin\BusinessRulesAction\ShowMessage::execute()

Execute the action.

Parameters

\Drupal\business_rules\ActionInterface $action: The configured action.

\Drupal\business_rules\Events\BusinessRulesEvent $event: The event that has triggered the action.

Return value

array The render array to be showed on debug block.

Overrides BusinessRulesActionPlugin::execute

File

src/Plugin/BusinessRulesAction/ShowMessage.php, line 61

Class

ShowMessage
Class ShowMessage.

Namespace

Drupal\business_rules\Plugin\BusinessRulesAction

Code

public function execute(ActionInterface $action, BusinessRulesEvent $event) {
  $variables = $event
    ->getArgument('variables');
  $message = $action
    ->getSettings('message');
  $message_type = $action
    ->getSettings('message_type');
  $message = $this
    ->processVariables($message, $variables);
  $message = nl2br($message);
  $message = Xss::filterAdmin($message);
  $message = new FormattableMarkup($message, []);
  drupal_set_message($message, $message_type);
  $result = [
    '#type' => 'markup',
    '#markup' => t('Message type: %type, text: %message showed.', [
      '%message' => $message,
      '%type' => $message_type,
    ]),
  ];
  return $result;
}