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'
1 service uses MaintenanceModeSubscriber
File
- src/
EventSubscriber/ MaintenanceModeSubscriber.php, line 10
Namespace
Drupal\nagios\EventSubscriberView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MaintenanceModeSubscriber:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
MaintenanceModeSubscriber:: |
public | function | Make the status page available when Drupal is in maintenance mode. |