public function MaintenanceModeSubscriber::onKernelRequestMaintenance in Zircon Profile 8
Same name in this branch
- 8 core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php \Drupal\Core\EventSubscriber\MaintenanceModeSubscriber::onKernelRequestMaintenance()
- 8 core/modules/user/src/EventSubscriber/MaintenanceModeSubscriber.php \Drupal\user\EventSubscriber\MaintenanceModeSubscriber::onKernelRequestMaintenance()
Same name and namespace in other branches
- 8.0 core/modules/user/src/EventSubscriber/MaintenanceModeSubscriber.php \Drupal\user\EventSubscriber\MaintenanceModeSubscriber::onKernelRequestMaintenance()
Logout users if site is in maintenance mode.
Parameters
\Symfony\Component\HttpKernel\Event\GetResponseEvent $event: The event to process.
File
- core/
modules/ user/ src/ EventSubscriber/ MaintenanceModeSubscriber.php, line 58 - Contains \Drupal\user\EventSubscriber\MaintenanceModeSubscriber.
Class
- MaintenanceModeSubscriber
- Maintenance mode subscriber to logout users.
Namespace
Drupal\user\EventSubscriberCode
public function onKernelRequestMaintenance(GetResponseEvent $event) {
$request = $event
->getRequest();
$route_match = RouteMatch::createFromRequest($request);
if ($this->maintenanceMode
->applies($route_match)) {
// If the site is offline, log out unprivileged users.
if ($this->account
->isAuthenticated() && !$this->maintenanceMode
->exempt($this->account)) {
user_logout();
// Redirect to homepage.
$event
->setResponse($this
->redirect($this
->url('<front>')));
}
}
}