class LogoutFinalizer
Same name and namespace in other branches
- 11.x core/modules/user/src/LogoutFinalizer.php \Drupal\user\LogoutFinalizer
Finalize user logout.
Hierarchy
- class \Drupal\user\LogoutFinalizer
Expanded class hierarchy of LogoutFinalizer
6 files declare their use of LogoutFinalizer
- LogoutFinalizerTest.php in core/
modules/ user/ tests/ src/ Kernel/ LogoutFinalizerTest.php - MaintenanceModeSubscriber.php in core/
modules/ user/ src/ EventSubscriber/ MaintenanceModeSubscriber.php - user.module in core/
modules/ user/ user.module - UserAuthenticationController.php in core/
modules/ user/ src/ Controller/ UserAuthenticationController.php - UserController.php in core/
modules/ user/ src/ Controller/ UserController.php
File
-
core/
modules/ user/ src/ LogoutFinalizer.php, line 17
Namespace
Drupal\userView source
final readonly class LogoutFinalizer {
public function __construct(protected AccountProxyInterface $accountProxy, protected SessionManagerInterface $sessionManager, protected ModuleHandlerInterface $moduleHandler, #[Autowire(service: 'logger.channel.user')] protected LoggerInterface $logger) {
}
/**
* Logs the current user out.
*/
public function finalizeLogout() : void {
$this->logger
->info('Session closed for %name.', [
'%name' => $this->accountProxy
->getAccountName(),
]);
$this->moduleHandler
->invokeAll('user_logout', [
$this->accountProxy,
]);
// Destroy the current session, and reset $user to the anonymous user.
// Note: In Symfony the session is intended to be destroyed with
// Session::invalidate(). Regrettably this method is currently broken and
// may lead to the creation of spurious session records in the database.
// @see https://github.com/symfony/symfony/issues/12375
$this->sessionManager
->destroy();
$this->accountProxy
->setAccount(new AnonymousUserSession());
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.