You are here

protected function SearchApiSolrAcquiaConnector::getAcquiaSearchCores in Acquia Search 3.x

Outputs list of Acquia Search cores.

Return value

array Renderable array.

1 call to SearchApiSolrAcquiaConnector::getAcquiaSearchCores()
SearchApiSolrAcquiaConnector::buildConfigurationForm in src/Plugin/SolrConnector/SearchApiSolrAcquiaConnector.php
Form constructor.

File

src/Plugin/SolrConnector/SearchApiSolrAcquiaConnector.php, line 350

Class

SearchApiSolrAcquiaConnector
Class SearchApiSolrAcquiaConnector.

Namespace

Drupal\acquia_search\Plugin\SolrConnector

Code

protected function getAcquiaSearchCores() : array {
  if (!$this->storage
    ->getApiKey() || !$this->storage
    ->getIdentifier() || !$this->storage
    ->getUuid() || !$this->storage
    ->getApiHost()) {
    return [
      '#markup' => $this
        ->t('Please provide API credentials for Acquia Search.'),
    ];
  }
  if (!($cores = Runtime::getAcquiaSearchApiClient()
    ->getSearchIndexes($this->storage
    ->getIdentifier()))) {
    return [
      '#markup' => $this
        ->t('Unable to connect to Acquia Search API.'),
    ];
  }

  // We use core id as a key.
  $cores = array_keys($cores);
  if (empty($cores)) {
    $cores[] = $this
      ->t('Your subscription contains no cores.');
  }
  return [
    '#theme' => 'item_list',
    '#items' => $cores,
  ];
}