You are here

public function SearchApiElasticsearchConnector::viewSettings in Elasticsearch Connector 7.2

Same name and namespace in other branches
  1. 7.5 modules/elasticsearch_connector_search_api/service.inc \SearchApiElasticsearchConnector::viewSettings()
  2. 7 modules/elasticsearch_connector_search_api/service.inc \SearchApiElasticsearchConnector::viewSettings()

Overrides viewSettings().

Overrides SearchApiAbstractService::viewSettings

File

modules/elasticsearch_connector_search_api/service.inc, line 174
Provides a Elasticsearch-based service class for the Search API using Elasticsearch Connector module.

Class

SearchApiElasticsearchConnector
Search service class.

Code

public function viewSettings() {
  $output = array();
  $status = !empty($this->elasticsearchClient) ? $this->elasticsearchClient
    ->info() : NULL;
  $elasticsearch_connector_path = elasticsearch_connector_main_settings_path();
  $output['status'] = array(
    '#type' => 'item',
    '#title' => t('Elasticsearch cluster status'),
    '#markup' => '<div class="elasticsearch-daemon-status"><em>' . (elasticsearch_connector_check_status($status) ? 'running' : 'not running') . '</em>' . ' - <a href=" ' . url($elasticsearch_connector_path . '/clusters/' . $this->cluster_id . '/info') . ' ">' . t('More info') . '</a></div>',
  );

  // Display settings.
  $form = $form_state = array();
  $option_form = $this
    ->configurationForm($form, $form_state);
  $option_form['#title'] = t('Elasticsearch server settings');
  $element = $this
    ->parseOptionFormElement($option_form, 'options');
  if (!empty($element)) {
    $settings = '';
    foreach ($element['option'] as $sub_element) {
      $settings .= $this
        ->viewSettingElement($sub_element);
    }
    $output['settings'] = array(
      '#type' => 'fieldset',
      '#title' => $element['label'],
    );
    $output['settings'][] = array(
      '#type' => 'markup',
      '#markup' => '<div class="elasticsearch-server-settings">' . $settings . '</div>',
    );
  }
  return $output;
}