public function UserController::logout in Drupal 10
Same name and namespace in other branches
- 8 core/modules/user/src/Controller/UserController.php \Drupal\user\Controller\UserController::logout()
- 9 core/modules/user/src/Controller/UserController.php \Drupal\user\Controller\UserController::logout()
Logs the current user out.
Return value
\Symfony\Component\HttpFoundation\RedirectResponse A redirection to home page.
1 string reference to 'UserController::logout'
- user.routing.yml in core/
modules/ user/ user.routing.yml - core/modules/user/user.routing.yml
File
- core/
modules/ user/ src/ Controller/ UserController.php, line 317
Class
- UserController
- Controller routines for user routes.
Namespace
Drupal\user\ControllerCode
public function logout() {
if ($this
->currentUser()
->isAuthenticated()) {
user_logout();
}
return $this
->redirect('<front>');
}