You are here

public function PreferredSearchCore::getPreferredCore in Acquia Search 3.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', ].

3 calls to PreferredSearchCore::getPreferredCore()
PreferredSearchCore::getPreferredCoreHostname in src/PreferredSearchCore.php
Returns expected core host based on the current site configs.
PreferredSearchCore::getPreferredCoreId in src/PreferredSearchCore.php
Returns expected core ID based on the current site configs.
PreferredSearchCore::isPreferredCoreAvailable in src/PreferredSearchCore.php
Determines whether the expected core ID matches any available core IDs.

File

src/PreferredSearchCore.php, line 149

Class

PreferredSearchCore
Return the Preferred search core for Solr.

Namespace

Drupal\acquia_search

Code

public function getPreferredCore() : ?array {
  if (!empty($this->preferredCore)) {
    return $this->preferredCore;
  }
  $expected_cores = $this
    ->getListOfPossibleCores();
  $available_cores = $this->availableCores;
  foreach ($expected_cores as $expected_core) {
    foreach ($available_cores as $available_core) {
      if ($expected_core === $available_core['core_id']) {
        $this->preferredCore = $available_core;
        return $this->preferredCore;
      }
    }
  }
  return NULL;
}