class EnvironmentSubscriber in Environment 8
Hierarchy
- class \Drupal\environment\EventSubscriber\EnvironmentSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of EnvironmentSubscriber
1 string reference to 'EnvironmentSubscriber'
1 service uses EnvironmentSubscriber
File
- src/
EventSubscriber/ EnvironmentSubscriber.php, line 8
Namespace
Drupal\environment\EventSubscriberView source
class EnvironmentSubscriber implements EventSubscriberInterface {
public function checkForEnvironmentSwitch(GetResponseEvent $event) {
$env_req_override = \Drupal::config('environment.settings')
->get('environment_require_override');
if ($env_req_override) {
$env_override = \Drupal::config('environment.settings')
->get('environment_override');
if (!empty($env_override)) {
$current_env = environment_current(FALSE);
if ($current_env != $env_override) {
environment_switch($env_override, TRUE);
}
}
}
}
/**
* {@inheritdoc}
*/
static function getSubscribedEvents() {
$events[KernelEvents::REQUEST][] = array(
'checkForEnvironmentSwitch',
);
return $events;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EnvironmentSubscriber:: |
public | function | ||
EnvironmentSubscriber:: |
static | function | Returns an array of event names this subscriber wants to listen to. |