You are here

public function SearchApiSolrAcquiaConnector::defaultConfiguration in Acquia Search 2.x

Same name and namespace in other branches
  1. 3.x src/Plugin/SolrConnector/SearchApiSolrAcquiaConnector.php \Drupal\acquia_search\Plugin\SolrConnector\SearchApiSolrAcquiaConnector::defaultConfiguration()

Gets default configuration for this plugin.

Return value

array An associative array with the default configuration.

Overrides SolrConnectorPluginBase::defaultConfiguration

File

src/Plugin/SolrConnector/SearchApiSolrAcquiaConnector.php, line 49

Class

SearchApiSolrAcquiaConnector
Acquia Search Plugin for Search API Solr.

Namespace

Drupal\acquia_search\Plugin\SolrConnector

Code

public function defaultConfiguration() {
  $configuration = parent::defaultConfiguration();
  $storage = new Storage();
  $configuration['index_id'] = $storage
    ->getIdentifier();
  $configuration['path'] = '/';
  $configuration['host'] = acquia_search_get_search_host();
  $configuration['scheme'] = empty($configuration['scheme']) ? 'http' : $configuration['scheme'];
  $default_port = $configuration['scheme'] == 'https' ? 443 : 80;
  $configuration['port'] = empty($configuration['port']) ? $default_port : $configuration['port'];
  unset($configuration['overridden_by_acquia_search']);

  // If auto-switch feature is turned off - do not attempt to determine the
  // preferred core.
  if (acquia_search_is_auto_switch_disabled()) {
    return $configuration;
  }

  // If the search config is overridden in settings.php, apply this config
  // to the Solr connection and don't attempt to determine the preferred
  // core.
  if (acquia_search_is_connection_config_overridden()) {
    $configuration = $this
      ->setOverriddenCore($configuration);
    return $configuration;
  }
  $preferred_core_service = acquia_search_get_core_service();

  // If the preferred core available, set it.
  if ($preferred_core_service
    ->isPreferredCoreAvailable()) {
    $configuration = $this
      ->setPreferredCore($configuration, $preferred_core_service);
  }
  else {

    // This means we can't detect which search core should be used, so we
    // need to protect it by setting read-only mode but only if it applies.
    if (acquia_search_should_set_read_only_mode()) {
      $configuration = $this
        ->setReadOnlyMode($configuration);
    }
  }
  return $configuration;
}