You are here

function acquia_search_disable in Acquia Connector 7.3

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

Implements hook_disable().

File

acquia_search/acquia_search.install, line 104
Install file.

Code

function acquia_search_disable() {

  // Remove the base Acquia Search environment we added.
  apachesolr_environment_delete(ACQUIA_SEARCH_ENVIRONMENT_ID);
  apachesolr_environment_delete(ACQUIA_SEARCH_V3_ENVIRONMENT_ID);

  // Unset all other acquia search environments.
  $environments = apachesolr_load_all_environments();
  foreach ($environments as $environment) {
    if (!empty($environment['service_class']) && $environment['service_class'] === AcquiaSearchSolrService::class) {

      // Remove traces of acquia_search.
      // Unset our acquia url and set it back to default.
      $environment['url'] = 'http://localhost:8983/solr';

      // Emptying the service class, unsetting it would not work, since it would
      // not overwrite the old value.
      $environment['service_class'] = '';
      apachesolr_environment_save($environment);
    }
  }
  variable_del('acquia_search_derived_key_salt');
  variable_del('apachesolr_default_environment');

  // Make sure apachesolr search is the default search module.
  variable_set('search_default_module', 'apachesolr_search');
}