public function AutologoutController::ajaxGetRemainingTime in Automated Logout 8
AJAX callback that returns the time remaining for this user is logged out.
1 string reference to 'AutologoutController::ajaxGetRemainingTime'
File
- src/
Controller/ AutologoutController.php, line 108
Class
- AutologoutController
- Returns responses for autologout module routes.
Namespace
Drupal\autologout\ControllerCode
public function ajaxGetRemainingTime() {
$req = \Drupal::requestStack()
->getCurrentRequest();
$active = $req
->get('uactive');
$response = new AjaxResponse();
if (isset($active) && $active === "false") {
$response
->addCommand(new ReplaceCommand('#timer', 0));
$response
->addCommand(new SettingsCommand([
'time' => 0,
]));
return $response;
}
$time_remaining_ms = $this->autoLogoutManager
->getRemainingTime() * 1000;
// Reset the timer.
$markup = $this->autoLogoutManager
->createTimer();
$response
->addCommand(new ReplaceCommand('#timer', $markup));
$response
->addCommand(new SettingsCommand([
'time' => $time_remaining_ms,
]));
return $response;
}