function SessionTestController::traceHandlerRewriteUnmodified
Returns an updated trace recorded by test proxy session handlers as JSON.
The session data is rewritten without modification to invoke `\SessionUpdateTimestampHandlerInterface::updateTimestamp`.
Expects that there is an existing stacked session handler trace as recorded by `traceHandler()`.
Parameters
\Symfony\Component\HttpFoundation\Request $request: The incoming request.
Return value
\Symfony\Component\HttpFoundation\JsonResponse The response.
Throws
\AssertionError
1 string reference to 'SessionTestController::traceHandlerRewriteUnmodified'
- 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 190
Class
- SessionTestController
- Controller providing page callbacks for the action admin interface.
Namespace
Drupal\session_test\ControllerCode
public function traceHandlerRewriteUnmodified(Request $request) {
// Assert that there is an existing session with stacked handler trace data.
assert(is_int($_SESSION['trace-handler']) && $_SESSION['trace-handler'] > 0, 'Existing stacked session handler trace not found');
// Save unmodified session data.
assert(ini_get('session.lazy_write'), 'session.lazy_write must be enabled to invoke updateTimestamp()');
$request->getSession()
->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.