You are here

protected function IndexSolrMultisiteCloneForm::getServerOptions in Search API Solr 4.x

Same name and namespace in other branches
  1. 8.3 src/Form/IndexSolrMultisiteCloneForm.php \Drupal\search_api_solr\Form\IndexSolrMultisiteCloneForm::getServerOptions()

Retrieves all available servers as an options list.

Return value

string[] An associative array mapping server IDs to their labels.

Throws

\Drupal\Component\Plugin\Exception\PluginNotFoundException

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\search_api\SearchApiException

File

src/Form/IndexSolrMultisiteCloneForm.php, line 117

Class

IndexSolrMultisiteCloneForm
Provides a form for the Index entity.

Namespace

Drupal\search_api_solr\Form

Code

protected function getServerOptions() {
  $options = [];

  /** @var \Drupal\search_api\ServerInterface[] $servers */
  $servers = $this->entityTypeManager
    ->getStorage('search_api_server')
    ->loadMultiple();
  foreach ($servers as $server_id => $server) {
    if ($server
      ->getBackend() instanceof SolrBackendInterface) {

      // @todo Special formatting for disabled servers.
      $options[$server_id] = SearchApiUtility::escapeHtml($server
        ->label());
    }
  }
  return $options;
}