"Fossies" - the Fresh Open Source Software Archive

Member "drupal-8.9.9/core/lib/Drupal/Core/Site/MaintenanceMode.php" (18 Nov 2020, 1128 Bytes) of package /linux/www/drupal-8.9.9.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "MaintenanceMode.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 
    3 namespace Drupal\Core\Site;
    4 
    5 use Drupal\Core\Routing\RouteMatchInterface;
    6 use Drupal\Core\Session\AccountInterface;
    7 use Drupal\Core\State\StateInterface;
    8 
    9 /**
   10  * Provides the default implementation of the maintenance mode service.
   11  */
   12 class MaintenanceMode implements MaintenanceModeInterface {
   13 
   14   /**
   15    * The state.
   16    *
   17    * @var \Drupal\Core\State\StateInterface
   18    */
   19   protected $state;
   20 
   21   /**
   22    * Constructs a new maintenance mode service.
   23    *
   24    * @param \Drupal\Core\State\StateInterface $state
   25    *   The state.
   26    */
   27   public function __construct(StateInterface $state) {
   28     $this->state = $state;
   29   }
   30 
   31   /**
   32    * {@inheritdoc}
   33    */
   34   public function applies(RouteMatchInterface $route_match) {
   35     if (!$this->state->get('system.maintenance_mode')) {
   36       return FALSE;
   37     }
   38 
   39     if ($route = $route_match->getRouteObject()) {
   40       if ($route->getOption('_maintenance_access')) {
   41         return FALSE;
   42       }
   43     }
   44 
   45     return TRUE;
   46   }
   47 
   48   /**
   49    * {@inheritdoc}
   50    */
   51   public function exempt(AccountInterface $account) {
   52     return $account->hasPermission('access site in maintenance mode');
   53   }
   54 
   55 }