You are here

function acquia_search_get_environment in Acquia Connector 7.3

Same name and namespace in other branches
  1. 7 acquia_search/acquia_search.module \acquia_search_get_environment()
  2. 7.2 acquia_search/acquia_search.module \acquia_search_get_environment()

Predefined Acquia Search network environment.

5 calls to acquia_search_get_environment()
AcquiaSearchWebTestCase::setUp in acquia_search/tests/acquia_search.test
Overrides DrupalTestCase::setUp().
acquia_search_enable_acquia_solr_environment in acquia_search/acquia_search.module
Create a new record pointing to the Acquia apachesolr search server.
acquia_search_environment_edit_form_validate in acquia_search/acquia_search.module
Ensures environment parameters are unchanged.
acquia_search_form_apachesolr_environment_edit_form_alter in acquia_search/acquia_search.module
Implements hook_form_FORM_ID_alter().
_acquia_make_environment_url in acquia_search/acquia_search.module
Ajjax callback to set enviroment fields in form.

File

acquia_search/acquia_search.module, line 286
Integration between Acquia Drupal and Acquia's hosted solr search service.

Code

function acquia_search_get_environment($conf = array()) {
  if (!empty($conf['acquia_subscription_id']) && !empty($conf['acquia_subscription_key'])) {
    $identifier = $conf['acquia_subscription_id'];
    $key = $conf['acquia_subscription_key'];
    $subscription = acquia_agent_get_subscription($params = array(), $identifier, $key);
  }
  else {
    $identifier = acquia_agent_settings('acquia_identifier');
    $subscription = acquia_agent_settings('acquia_subscription_data');
  }
  $search_host = variable_get('acquia_search_host', 'search.acquia.com');

  // @todo rework this logic once we have AH_SERVER_REGION
  // legacy_internal will be true if 'internal-' is the start of the host
  // name that's set in via Acquia Cloud platform or vset.
  $legacy_internal = preg_match('/internal[-.]/', $search_host);

  // Adding the subscription specific colony to the heartbeat data.
  if (!empty($subscription['heartbeat_data']['search_service_colony'])) {
    $search_host = $subscription['heartbeat_data']['search_service_colony'];
    if ($legacy_internal) {

      // If we want to be using an internal host name, fix the one
      // from the hearbeat data here.
      $search_host = 'internal-' . $search_host;
    }
  }

  // Check if we are on Acquia Cloud hosting. @see NN-2503.
  if (!empty($_ENV['AH_SITE_ENVIRONMENT']) && !empty($_ENV['AH_SERVER_REGION'])) {
    if ($_ENV['AH_SERVER_REGION'] == 'us-east-1' && $search_host == 'search.acquia.com') {
      $search_host = 'internal-search.acquia.com';
    }
    elseif (strpos($search_host, 'search-' . $_ENV['AH_SERVER_REGION']) === 0) {
      $search_host = 'internal-' . $search_host;
    }
  }
  $environment = array(
    'url' => 'http://' . $search_host . variable_get('acquia_search_path', '/solr/' . $identifier),
    'service_class' => 'AcquiaSearchService',
  );
  return $environment;
}