You are here

class AcquiaSearchTestSubscriber in Acquia Connector 8

Event Subscriber test for Acquia Search on Solarium.

Hierarchy

  • class \Drupal\acquia_search_test\EventSubscriber\AcquiaSearchTestSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of AcquiaSearchTestSubscriber

1 string reference to 'AcquiaSearchTestSubscriber'
acquia_search_test.services.yml in acquia_search/tests/modules/acquia_search_test/acquia_search_test.services.yml
acquia_search/tests/modules/acquia_search_test/acquia_search_test.services.yml
1 service uses AcquiaSearchTestSubscriber
acquia_search_test_event_subscriber in acquia_search/tests/modules/acquia_search_test/acquia_search_test.services.yml
Drupal\acquia_search_test\EventSubscriber\AcquiaSearchTestSubscriber

File

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

Namespace

Drupal\acquia_search_test\EventSubscriber
View source
class AcquiaSearchTestSubscriber implements EventSubscriberInterface {

  /**
   * Injects $_GET parameters from URLs into the some global $_ENV.
   *
   * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
   *   The Event to process.
   */
  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;
        }
      }
    }
  }

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {

    // Add our event with a high priority (1000) to ensure it runs before
    // the Solr connection is decided on.
    $events[KernelEvents::REQUEST][] = [
      'checkForOverrides',
      1000,
    ];
    return $events;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AcquiaSearchTestSubscriber::checkForOverrides public function Injects $_GET parameters from URLs into the some global $_ENV.
AcquiaSearchTestSubscriber::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.