function SessionTestController::setMessage

Same name and namespace in other branches
  1. 9 core/modules/system/tests/modules/session_test/src/Controller/SessionTestController.php \Drupal\session_test\Controller\SessionTestController::setMessage()
  2. 8.9.x core/modules/system/tests/modules/session_test/src/Controller/SessionTestController.php \Drupal\session_test\Controller\SessionTestController::setMessage()
  3. 10 core/modules/system/tests/modules/session_test/src/Controller/SessionTestController.php \Drupal\session_test\Controller\SessionTestController::setMessage()

Sets a message to me displayed on the following page.

Return value

string A notification message.

1 call to SessionTestController::setMessage()
SessionTestController::setMessageButDoNotSave in core/modules/system/tests/modules/session_test/src/Controller/SessionTestController.php
Sets a message but call drupal_save_session(FALSE).
1 string reference to 'SessionTestController::setMessage'
session_test.routing.yml in core/modules/system/tests/modules/session_test/session_test.routing.yml
core/modules/system/tests/modules/session_test/session_test.routing.yml

File

core/modules/system/tests/modules/session_test/src/Controller/SessionTestController.php, line 112

Class

SessionTestController
Controller providing page callbacks for the action admin interface.

Namespace

Drupal\session_test\Controller

Code

public function setMessage() {
    $this->messenger()
        ->addStatus($this->t('This is a dummy message.'));
    return new Response($this->t('A message was set.'));
    // Do not return anything, so the current request does not result in a themed
    // page with messages. The message will be displayed in the following request
    // instead.
}

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