function SessionTestController::hasSessionBagFlag

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::hasSessionBagFlag()
  2. 8.9.x core/modules/system/tests/modules/session_test/src/Controller/SessionTestController.php \Drupal\session_test\Controller\SessionTestController::hasSessionBagFlag()
  3. 10 core/modules/system/tests/modules/session_test/src/Controller/SessionTestController.php \Drupal\session_test\Controller\SessionTestController::hasSessionBagFlag()

Prints a message if the flag in the session bag is set.

Parameters

\Symfony\Component\HttpFoundation\Request $request: The request object.

1 string reference to 'SessionTestController::hasSessionBagFlag'
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 238

Class

SessionTestController
Controller providing page callbacks for session tests.

Namespace

Drupal\session_test\Controller

Code

public function hasSessionBagFlag(Request $request) : Response {
  /** @var \Drupal\session_test\Session\TestSessionBag */
  $bag = $request->getSession()
    ->getBag(TestSessionBag::BAG_NAME);
  return new Response(empty($bag->hasFlag()) ? (string) $this->t('Flag is absent from session bag') : (string) $this->t('Flag is present in session bag'));
}

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