function SessionTestController::traceHandler

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

Returns the trace recorded by test proxy session handlers as JSON.

Parameters

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

1 string reference to 'SessionTestController::traceHandler'
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 134

Class

SessionTestController
Controller providing page callbacks for session tests.

Namespace

Drupal\session_test\Controller

Code

public function traceHandler(Request $request) : Response {
  // Increment trace-handler counter and save the session.
  $session = $request->getSession();
  $counter = $session->get('trace-handler', 0);
  $session->set('trace-handler', $counter + 1);
  $session->save();
  // Collect traces and return them in JSON format.
  $trace = \Drupal::service('session_test.session_handler_proxy_trace')->getArrayCopy();
  return new JsonResponse($trace);
}

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