function MaintenanceModeSubscriber::onMaintenanceModeRequest

Same name in this branch
  1. 10 core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php \Drupal\Core\EventSubscriber\MaintenanceModeSubscriber::onMaintenanceModeRequest()
Same name in other branches
  1. 9 core/modules/user/src/EventSubscriber/MaintenanceModeSubscriber.php \Drupal\user\EventSubscriber\MaintenanceModeSubscriber::onMaintenanceModeRequest()
  2. 9 core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php \Drupal\Core\EventSubscriber\MaintenanceModeSubscriber::onMaintenanceModeRequest()
  3. 11.x core/modules/user/src/EventSubscriber/MaintenanceModeSubscriber.php \Drupal\user\EventSubscriber\MaintenanceModeSubscriber::onMaintenanceModeRequest()
  4. 11.x core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php \Drupal\Core\EventSubscriber\MaintenanceModeSubscriber::onMaintenanceModeRequest()

Logout users if site is in maintenance mode and user is not exempt.

Parameters

\Symfony\Component\HttpKernel\Event\RequestEvent $event: The event to process.

File

core/modules/user/src/EventSubscriber/MaintenanceModeSubscriber.php, line 49

Class

MaintenanceModeSubscriber
Maintenance mode subscriber to log out users.

Namespace

Drupal\user\EventSubscriber

Code

public function onMaintenanceModeRequest(RequestEvent $event) {
    // If the site is offline, log out unprivileged users.
    if ($this->account
        ->isAuthenticated()) {
        user_logout();
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.