You are here

class MaintenanceModeSubscriber in Nagios Monitoring 8

Hierarchy

  • class \Drupal\nagios\EventSubscriber\MaintenanceModeSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of MaintenanceModeSubscriber

1 file declares its use of MaintenanceModeSubscriber
MaintenanceModeTest.php in tests/src/Kernel/MaintenanceModeTest.php
1 string reference to 'MaintenanceModeSubscriber'
nagios.services.yml in ./nagios.services.yml
nagios.services.yml
1 service uses MaintenanceModeSubscriber
nagios.maintenance_mode_subscriber in ./nagios.services.yml
Drupal\nagios\EventSubscriber\MaintenanceModeSubscriber

File

src/EventSubscriber/MaintenanceModeSubscriber.php, line 10

Namespace

Drupal\nagios\EventSubscriber
View source
class MaintenanceModeSubscriber implements EventSubscriberInterface {

  /**
   * Make the status page available when Drupal is in maintenance mode.
   *
   * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
   *   The event to process.
   */
  public function onKernelRequestMaintenance(GetResponseEvent $event) {
    $config = \Drupal::config('nagios.settings');
    $request = $event
      ->getRequest();
    $nagios_path = '/' . $config
      ->get('nagios.statuspage.path');
    if ($request
      ->getPathInfo() === $nagios_path) {
      $oController = new StatuspageController();
      if ($oController
        ->access()
        ->isAllowed()) {
        $event
          ->setResponse($oController
          ->content());
      }
    }
  }

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    $events[KernelEvents::REQUEST][] = [
      'onKernelRequestMaintenance',
      35,
    ];
    return $events;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MaintenanceModeSubscriber::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.
MaintenanceModeSubscriber::onKernelRequestMaintenance public function Make the status page available when Drupal is in maintenance mode.