You are here

public function PreferredSearchCoreService::getPreferredCore in Acquia Search 2.x

Returns the preferred core from the list of available cores.

Return value

array|null NULL or [ 'balancer' => 'useast11-c4.acquia-search.com', 'core_id' => 'WXYZ-12345.dev.mysitedev', ].

4 calls to PreferredSearchCoreService::getPreferredCore()
PreferredSearchCoreService::getPreferredCoreHostname in src/PreferredSearchCoreService.php
Returns expected core host based on the current site configs.
PreferredSearchCoreService::getPreferredCoreId in src/PreferredSearchCoreService.php
Returns expected core ID based on the current site configs.
PreferredSearchCoreService::getPreferredCoreUrl in src/PreferredSearchCoreService.php
Returns URL for the preferred search core.
PreferredSearchCoreService::isPreferredCoreAvailable in src/PreferredSearchCoreService.php
Determines whether the expected core ID matches any available core IDs.

File

src/PreferredSearchCoreService.php, line 139

Class

PreferredSearchCoreService
Serivce to check for preferred search core.

Namespace

Drupal\acquia_search

Code

public function getPreferredCore() {
  static $preferred_core;
  if (!empty($preferred_core)) {
    return $preferred_core;
  }
  $expected_cores = $this
    ->getListOfPossibleCores();
  $available_cores_sorted = $this
    ->sortCores($this->availableCores);
  foreach ($expected_cores as $expected_core) {
    foreach ($available_cores_sorted as $available_core) {
      if ($expected_core == $available_core['core_id']) {
        $preferred_core = $available_core;
        return $preferred_core;
      }
    }
  }
}