The logout controller seems to do(UserController::logout()
) does this in a separate step:
\Drupal\user\Controller\UserController::logout.
public function logout() {
user_logout();
return $this->redirect('<front>');
}
You can alter the controller class infor the route user.logout
user.logout route to replace this with custom code. The question is, what
What do you want to do instead, because to build? Building an anonymous response a redirect seems to be the most straightforward solution.