You are here

public function SearchApiAcquiaSearchMultiService::setConnectionOptions in Acquia Search Multiple Indexes 7

Same name and namespace in other branches
  1. 8 src/Plugin/search_api/backend/SearchApiAcquiaSearchMultiService.php \SearchApiAcquiaSearchMultiService::setConnectionOptions()
3 calls to SearchApiAcquiaSearchMultiService::setConnectionOptions()
SearchApiAcquiaSearchMultiService::connect in lib/Drupal/SearchApiSolr/SearchApiAcquiaSearchMultiService.php
SearchApiAcquiaSearchMultiService::getExtraInformation in lib/Drupal/SearchApiSolr/SearchApiAcquiaSearchMultiService.php
SearchApiAcquiaSearchMultiService::viewSettings in lib/Drupal/SearchApiSolr/SearchApiAcquiaSearchMultiService.php

File

lib/Drupal/SearchApiSolr/SearchApiAcquiaSearchMultiService.php, line 27
Contains SearchApiAcquiaSearchMultiService.

Class

SearchApiAcquiaSearchMultiService
Provides automatic environment switching for Acquia Search servers.

Code

public function setConnectionOptions() {
  $has_id = isset($this->options['acquia_override_subscription']['acquia_override_subscription_id']) ? true : false;
  $has_key = isset($this->options['acquia_override_subscription']['acquia_override_subscription_key']) ? true : false;
  $has_corename = isset($this->options['acquia_override_subscription']['acquia_override_subscription_corename']) ? true : false;
  if ($has_id && $has_key && $has_corename) {
    $identifier = $this->options['acquia_override_subscription']['acquia_override_subscription_id'];
    $key = $this->options['acquia_override_subscription']['acquia_override_subscription_key'];
    $corename = $this->options['acquia_override_subscription']['acquia_override_subscription_corename'];
    $this->options['path'] = '/solr/' . $corename;

    // Set the derived key for this environment.
    $subscription = $this
      ->getAcquiaSubscription($identifier, $key);
    if (!$this
      ->getAcquiaSubscriptionError($subscription, $identifier)) {
      $derived_key_salt = $subscription['derived_key_salt'];
      $derived_key = _acquia_search_multi_subs_create_derived_key($derived_key_salt, $corename, $key);
      $this->options['derived_key'] = $derived_key;

      // Get and set our search core hostname.
      $search_host = acquia_search_multi_subs_get_hostname($corename);
      $this->options['host'] = $search_host;
    }
  }
  else {
    parent::setConnectionOptions();
  }
}