You are here

public function SearchApiElasticsearchBackend::viewSettings in Elasticsearch Connector 8

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.2 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()

Overrides viewSettings().

Overrides BackendPluginBase::viewSettings

File

src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php, line 204
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 = array();
  $serverlink = $this
    ->getServerLink();
  $info[] = array(
    'label' => $this
      ->t('Elasticsearch server URI'),
    'info' => \Drupal::l($serverlink, Url::fromUri($serverlink)),
  );
  if ($this->server
    ->status()) {

    // If the server is enabled, check whether Elasticsearch can be reached.
    $ping = $this
      ->ping();
    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[] = array(
      'label' => $this
        ->t('Connection'),
      'info' => $msg,
      'status' => $ping ? 'ok' : 'error',
    );
  }
  return $info;
}