You are here

function acquia_search_enable_acquia_solr_environment in Acquia Search 6.3

Create a new record pointing to the Acquia apachesolr search server and set it as the default

2 calls to acquia_search_enable_acquia_solr_environment()
AcquiaSearchWebTestCase::enableEnvironment in tests/acquia_search.test
Enables the environment of Acquia Search.
acquia_search_acquia_subscription_status in ./acquia_search.module
Implementation of hook_acquia_subscription_status().

File

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

Code

function acquia_search_enable_acquia_solr_environment() {

  // Creates the new environment
  $environment = apachesolr_environment_load(ACQUIA_SEARCH_ENVIRONMENT_ID, $reset = TRUE);
  if (!$environment) {

    // Only set the default if we just created the environment.
    // This will almost always happen, unless the module was disabled via SQL.
    variable_set('apachesolr_default_environment', ACQUIA_SEARCH_ENVIRONMENT_ID);
    $environment['conf'] = array();

    // Also make sure that the default search page has Acquia Search as its
    // default environment
    $default_search_page_id = apachesolr_search_default_search_page();
    $default_search_page = apachesolr_search_page_load($default_search_page_id);
    if (!empty($default_search_page) && $default_search_page['env_id'] != ACQUIA_SEARCH_ENVIRONMENT_ID) {
      $default_search_page['env_id'] = ACQUIA_SEARCH_ENVIRONMENT_ID;
      apachesolr_search_page_save($default_search_page);
    }
  }
  $acquia_environment = acquia_search_get_environment();

  // Manual merge because we have 1 level deeper (conf) and we would override
  // the conf variable if we did an automatic merge
  $environment['url'] = $acquia_environment['url'];
  $environment['service_class'] = $acquia_environment['service_class'];
  $environment['conf']['service_class_info'] = $acquia_environment['conf']['service_class_info'];

  //$environment = array_merge($acquia_environment, $environment);
  $environment['env_id'] = ACQUIA_SEARCH_ENVIRONMENT_ID;
  $environment['name'] = t('Acquia Search');
  apachesolr_environment_save($environment);
}