You are here

public function AcquiaSearchTestSubscriber::checkForOverrides in Acquia Connector 8

Injects $_GET parameters from URLs into the some global $_ENV.

Parameters

\Symfony\Component\HttpKernel\Event\GetResponseEvent $event: The Event to process.

File

acquia_search/tests/modules/acquia_search_test/src/EventSubscriber/AcquiaSearchTestSubscriber.php, line 20

Class

AcquiaSearchTestSubscriber
Event Subscriber test for Acquia Search on Solarium.

Namespace

Drupal\acquia_search_test\EventSubscriber

Code

public function checkForOverrides(GetResponseEvent $event) {
  if ($event
    ->getRequest()->query
    ->get('env-overrides')) {
    $allowed_keys = [
      'AH_SITE_ENVIRONMENT',
      'AH_SITE_NAME',
      'AH_SITE_GROUP',
      'AH_PRODUCTION',
    ];
    foreach ($allowed_keys as $key) {
      $value = $event
        ->getRequest()->query
        ->get($key);
      if (!empty($value)) {
        \Drupal::messenger()
          ->addMessage('acquia_search_test() module set $_ENV[' . $key . '] to ' . $value);
        $_ENV[$key] = $value;
      }
    }
  }
}