You are here

public function SearchApiElasticsearchBackend::viewSettings in Elasticsearch Connector 8.2

Same name and namespace in other branches
  1. 8.7 src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php \Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend::viewSettings()
  2. 8 src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php \Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend::viewSettings()
  3. 8.5 src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php \Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend::viewSettings()
  4. 8.6 src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php \Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend::viewSettings()

Return value

array

Throws

\Exception

Overrides BackendPluginBase::viewSettings

File

src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php, line 229
Contains the SearchApiElasticsearchBackend object.

Class

SearchApiElasticsearchBackend
Plugin annotation @SearchApiBackend( id = "elasticsearch", label = @Translation("Elasticsearch"), description = @Translation("Index items using an Elasticsearch server.") )

Namespace

Drupal\elasticsearch_connector\Plugin\search_api\backend

Code

public function viewSettings() {
  $info = [];
  $server_link = $this->cluster
    ->getSafeUrl();
  $info[] = [
    'label' => $this
      ->t('Elasticsearch server URI'),
    'info' => Link::fromTextAndUrl($server_link, Url::fromUri($server_link)),
  ];
  if ($this->server
    ->status()) {

    // If the server is enabled, check whether Elasticsearch can be reached.
    $ping = $this->client
      ->isClusterOk();
    if ($ping) {
      $msg = $this
        ->t('The Elasticsearch server could be reached');
    }
    else {
      $msg = $this
        ->t('The Elasticsearch server could not be reached. Further data is therefore unavailable.');
    }
    $info[] = [
      'label' => $this
        ->t('Connection'),
      'info' => $msg,
      'status' => $ping ? 'ok' : 'error',
    ];
  }
  return $info;
}