function TestControllers::testSession

Same name in other branches
  1. 8.9.x core/modules/system/tests/modules/menu_test/src/TestControllers.php \Drupal\menu_test\TestControllers::testSession()
  2. 10 core/modules/system/tests/modules/menu_test/src/TestControllers.php \Drupal\menu_test\TestControllers::testSession()
  3. 11.x core/modules/system/tests/modules/menu_test/src/TestControllers.php \Drupal\menu_test\TestControllers::testSession()

Prints out test data.

Parameters

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

Return value

array Render array.

1 string reference to 'TestControllers::testSession'
menu_test.routing.yml in core/modules/system/tests/modules/menu_test/menu_test.routing.yml
core/modules/system/tests/modules/menu_test/menu_test.routing.yml

File

core/modules/system/tests/modules/menu_test/src/TestControllers.php, line 43

Class

TestControllers
Controllers for testing the menu integration routing system.

Namespace

Drupal\menu_test

Code

public function testSession(Request $request) {
    $counter = $request->getSession()
        ->get('menu_test', 0);
    $request->getSession()
        ->set('menu_test', ++$counter);
    return [
        '#markup' => new FormattableMarkup('Session menu_test is @count', [
            '@count' => $counter,
        ]),
    ];
}

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