function RenderPlaceholderMessageTestController::setAndLogMessage

Same name in other branches
  1. 9 core/modules/system/tests/modules/render_placeholder_message_test/src/RenderPlaceholderMessageTestController.php \Drupal\render_placeholder_message_test\RenderPlaceholderMessageTestController::setAndLogMessage()
  2. 10 core/modules/system/tests/modules/render_placeholder_message_test/src/RenderPlaceholderMessageTestController.php \Drupal\render_placeholder_message_test\RenderPlaceholderMessageTestController::setAndLogMessage()
  3. 11.x 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>',
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.