state = $state; $this->config = $config_factory; } /** * {@inheritdoc} */ 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; } /** * {@inheritdoc} */ public function exempt(AccountInterface $account) { return $account->hasPermission('access site in maintenance mode'); } /** * {@inheritdoc} */ public function getSiteMaintenanceMessage() { return new FormattableMarkup($this->config->get('system.maintenance')->get('message'), [ '@site' => $this->config->get('system.site')->get('name'), ]); } }