You are here

public function SAPIPreferredSearchCoreService::getListOfPossibleCores in Acquia Search for Search API 7.2

Returns a list of all possible search core IDs.

The core 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 SAPIPreferredSearchCoreService::getListOfPossibleCores()
SAPIPreferredSearchCoreService::getPreferredCore in src/SAPIPreferredSearchCoreService.php
Returns the preferred core from the list of available cores.

File

src/SAPIPreferredSearchCoreService.php, line 141

Class

SAPIPreferredSearchCoreService
Class SAPIPreferredSearchCoreService.

Namespace

Drupal\search_api_acquia

Code

public function getListOfPossibleCores() {
  $possible_core_ids = array();

  // In index naming, we only accept alphanumeric chars.
  $sites_foldername = preg_replace('@[^a-zA-Z0-9]+@', '', $this->sites_foldername);
  $ah_env = preg_replace('@[^a-zA-Z0-9]+@', '', $this->ah_env);
  if ($ah_env) {

    // When there is an Acquia DB name defined, priority is to pick
    // WXYZ-12345.[env].[db_name], then WXYZ-12345.[env].[site_foldername].
    // If we're sure this is prod, then 3rd option is WXYZ-12345.
    if ($this->ah_db_name) {
      $possible_core_ids[] = $this->acquia_identifier . '.' . $ah_env . '.' . $this->ah_db_name;
    }
    $possible_core_ids[] = $this->acquia_identifier . '.' . $ah_env . '.' . $sites_foldername;

    // @TODO: Support for [id]_[env][sitename] cores?
  }

  // For production-only, we allow auto-connecting to the suffix-less core
  // as the fallback.
  if (isset($_SERVER['AH_PRODUCTION']) || isset($_ENV['AH_PRODUCTION'])) {
    $possible_core_ids[] = $this->acquia_identifier;
  }
  return $possible_core_ids;
}