You are here

public function AcquiaSearchSolrApi::getPreferredIndexService in Acquia Connector 7.3

Returns preferred search index service.

Return value

\AcquiaSearchSolrPreferredIndex Preferred search index service.

File

acquia_search/includes/AcquiaSearchSolrApi.php, line 169

Class

AcquiaSearchSolrApi
Class AcquiaSearchApi.

Code

public function getPreferredIndexService() {
  $ah_env = $_SERVER['AH_SITE_ENVIRONMENT'] ?? '';
  global $databases;
  $options = Database::getConnection()
    ->getConnectionOptions();
  $ah_db_name = $options['database'] ?? '';
  $ah_db_role = $this
    ->getDatabaseRole($databases, $ah_db_name);
  $sites_folder_name = substr(conf_path(), strrpos(conf_path(), '/') + 1);
  $available_indexes = $this
    ->getIndexes();
  $subscription = $this
    ->getSubscription();
  return new AcquiaSearchSolrPreferredIndex($subscription, $ah_env, $sites_folder_name, $ah_db_role, $available_indexes);
}