You are here

public function AcquiaSearchSolrPreferredIndex::getListOfPossibleIndexes in Acquia Connector 7.3

Returns a list of all possible search indexes IDs.

The index IDs are generated based on the current site configuration.

Return value

array E.g. [ 'WXYZ-12345', 'WXYZ-12345.dev.mysitedev_folder1', 'WXYZ-12345.dev.mysitedev_db', ]

1 call to AcquiaSearchSolrPreferredIndex::getListOfPossibleIndexes()
AcquiaSearchSolrPreferredIndex::getPreferredIndex in acquia_search/includes/AcquiaSearchSolrPreferredIndex.php
Returns the preferred index from the list of available search indexes.

File

acquia_search/includes/AcquiaSearchSolrPreferredIndex.php, line 123

Class

AcquiaSearchSolrPreferredIndex
Class AcquiaSearchSolrPreferredIndex.

Code

public function getListOfPossibleIndexes() {
  $indexes = [];

  // In index naming, we only accept alphanumeric chars.
  $pattern = '/[^a-zA-Z0-9]+/';
  $sitesFolder = preg_replace($pattern, '', $this->sitesFolderName);
  $ahEnv = preg_replace($pattern, '', $this->ahEnv);

  // The Acquia Search Solr module tries to use this index before any auto
  // detected index in case if it's set in the site configuration.
  $overriddenSearchIndex = variable_get('acquia_search_solr_search_index', '');
  if (!empty($overriddenSearchIndex)) {
    $indexes[] = $overriddenSearchIndex;
  }
  if (!empty($ahEnv)) {

    // When there is an Acquia DB role defined, priority is to pick
    // WXYZ-12345.[env].[db_role], then WXYZ-12345.[env].[site_foldername].
    if ($this->databaseRole) {
      $indexes[] = $this->acquiaIdentifier . '.' . $ahEnv . '.' . $this->databaseRole;
    }
    $indexes[] = $this->acquiaIdentifier . '.' . $ahEnv . '.' . $sitesFolder;
  }
  $context = [
    'environment_name' => $ahEnv,
    'database_role' => $this->databaseRole,
    'identifier' => $this->acquiaIdentifier,
    'sites_folder_name' => $sitesFolder,
  ];
  drupal_alter('acquia_search_solr_possible_indexes', $indexes, $context);
  return $indexes;
}