function SessionTestController::setMessage

Sets a message to me displayed on the following page.

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 104

Class

SessionTestController
Controller providing page callbacks for session tests.

Namespace

Drupal\session_test\Controller

Code

public function setMessage() : Response {
  $this->messenger()
    ->addStatus($this->t('This is a dummy message.'));
  return new Response((string) $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.