You are here

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'
environment.services.yml in ./environment.services.yml
environment.services.yml
1 service uses EnvironmentSubscriber
environment_event_subscriber in ./environment.services.yml
Drupal\environment\EventSubscriber\EnvironmentSubscriber

File

src/EventSubscriber/EnvironmentSubscriber.php, line 8

Namespace

Drupal\environment\EventSubscriber
View 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

Namesort descending Modifiers Type Description Overrides
EnvironmentSubscriber::checkForEnvironmentSwitch public function
EnvironmentSubscriber::getSubscribedEvents static function Returns an array of event names this subscriber wants to listen to.