You are here

public static function RenderPlaceholderMessageTestController::setAndLogMessage in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/system/tests/modules/render_placeholder_message_test/src/RenderPlaceholderMessageTestController.php \Drupal\render_placeholder_message_test\RenderPlaceholderMessageTestController::setAndLogMessage()

#lazy_builder callback; sets and prints a message.

Parameters

string $message: The message to send.

Return value

array A renderable array containing the message.

File

core/modules/system/tests/modules/render_placeholder_message_test/src/RenderPlaceholderMessageTestController.php, line 93

Class

RenderPlaceholderMessageTestController

Namespace

Drupal\render_placeholder_message_test

Code

public static function setAndLogMessage($message) {

  // Set message.
  \Drupal::messenger()
    ->addStatus($message);

  // Print which message is expected.
  return [
    '#markup' => '<p class="logged-message">Message: ' . $message . '</p>',
  ];
}