class AcsfMaintenanceModeSubscriber in Acquia Cloud Site Factory Connector 8.2
Same name and namespace in other branches
- 8 src/EventSubscriber/AcsfMaintenanceModeSubscriber.php \Drupal\acsf\EventSubscriber\AcsfMaintenanceModeSubscriber
Response subscriber to add SF maintenance mode header.
Hierarchy
- class \Drupal\acsf\EventSubscriber\AcsfMaintenanceModeSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of AcsfMaintenanceModeSubscriber
1 string reference to 'AcsfMaintenanceModeSubscriber'
1 service uses AcsfMaintenanceModeSubscriber
File
- src/
EventSubscriber/ AcsfMaintenanceModeSubscriber.php, line 13
Namespace
Drupal\acsf\EventSubscriberView source
class AcsfMaintenanceModeSubscriber implements EventSubscriberInterface {
/**
* Name of ACSF maintenance mode's response header.
*/
const HEADER = 'X-SF-Maintenance';
/**
* The state.
*
* @var \Drupal\Core\State\StateInterface
*/
protected $state;
/**
* Constructs a new AcsfMaintenanceModeSubscriber.
*
* @param \Drupal\Core\State\StateInterface $state
* The state.
*/
public function __construct(StateInterface $state) {
$this->state = $state;
}
/**
* Sets SF maintenance mode header (on successful responses).
*
* @param \Symfony\Component\HttpKernel\Event\FilterResponseEvent $event
* The event to process.
*/
public function onRespond(FilterResponseEvent $event) {
if (!$event
->isMasterRequest()) {
return;
}
if ($this->state
->get('system.maintenance_mode')) {
$response = $event
->getResponse();
$response->headers
->set(self::HEADER, 'enabled');
}
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[KernelEvents::RESPONSE][] = [
'onRespond',
];
return $events;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AcsfMaintenanceModeSubscriber:: |
protected | property | The state. | |
AcsfMaintenanceModeSubscriber:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
AcsfMaintenanceModeSubscriber:: |
constant | Name of ACSF maintenance mode's response header. | ||
AcsfMaintenanceModeSubscriber:: |
public | function | Sets SF maintenance mode header (on successful responses). | |
AcsfMaintenanceModeSubscriber:: |
public | function | Constructs a new AcsfMaintenanceModeSubscriber. |