You are here

public function PreferredSearchCoreService::getPreferredCore in Acquia Connector 8

Same name and namespace in other branches
  1. 7.3 acquia_search/src/PreferredSearchCoreService.php \Drupal\acquia_search\PreferredSearchCoreService::getPreferredCore()
  2. 7.2 acquia_search/src/PreferredSearchCoreService.php \Drupal\acquia_search\PreferredSearchCoreService::getPreferredCore()

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 acquia_search/src/PreferredSearchCoreService.php
Returns expected core host based on the current site configs.
PreferredSearchCoreService::getPreferredCoreId in acquia_search/src/PreferredSearchCoreService.php
Returns expected core ID based on the current site configs.
PreferredSearchCoreService::getPreferredCoreUrl in acquia_search/src/PreferredSearchCoreService.php
Returns URL for the preferred search core.
PreferredSearchCoreService::isPreferredCoreAvailable in acquia_search/src/PreferredSearchCoreService.php
Determines whether the expected core ID matches any available core IDs.

File

acquia_search/src/PreferredSearchCoreService.php, line 129

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;
      }
    }
  }
}