public function AutologoutManager::logout in Automated Logout 8
Perform Logout.
Helper to perform the actual logout. Destroys the session of the logged in user.
Overrides AutologoutManagerInterface::logout
File
- src/
AutologoutManager.php, line 192
Class
- AutologoutManager
- Defines an AutologoutManager service.
Namespace
Drupal\autologoutCode
public function logout() {
$user = $this->currentUser;
if ($this->autoLogoutSettings
->get('use_watchdog')) {
$this->logger
->info('Session automatically closed for %name by autologout.', [
'%name' => $user
->getAccountName(),
]);
}
// Destroy the current session.
$this->moduleHandler
->invokeAll('user_logout', [
$user,
]);
$this->session
->destroy();
$user
->setAccount(new AnonymousUserSession());
}