MaintenanceMode.php in Drupal 8
File
core/lib/Drupal/Core/Site/MaintenanceMode.php
View source
<?php
namespace Drupal\Core\Site;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\State\StateInterface;
class MaintenanceMode implements MaintenanceModeInterface {
protected $state;
public function __construct(StateInterface $state) {
$this->state = $state;
}
public function applies(RouteMatchInterface $route_match) {
if (!$this->state
->get('system.maintenance_mode')) {
return FALSE;
}
if ($route = $route_match
->getRouteObject()) {
if ($route
->getOption('_maintenance_access')) {
return FALSE;
}
}
return TRUE;
}
public function exempt(AccountInterface $account) {
return $account
->hasPermission('access site in maintenance mode');
}
}
Classes
Name |
Description |
MaintenanceMode |
Provides the default implementation of the maintenance mode service. |