You are here

public function SearchApiElasticsearchBackend::buildConfigurationForm 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::buildConfigurationForm()
  2. 8.2 src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php \Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend::buildConfigurationForm()
  3. 8.5 src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php \Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend::buildConfigurationForm()
  4. 8.6 src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php \Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend::buildConfigurationForm()

Overrides configurationForm().

File

src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php, line 94
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 buildConfigurationForm(array $form, FormStateInterface $form_state) {
  if (!$this->server
    ->isNew()) {
    $serverlink = $this
      ->getServerLink();

    // Editing this server
    $form['server_description'] = array(
      '#type' => 'item',
      '#title' => $this
        ->t('Elasticsearch Cluster'),
      '#description' => \Drupal::l($serverlink, Url::fromUri($serverlink)),
    );
  }
  $form['cluster_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('Elasticsearch settings'),
    '#tree' => FALSE,
  );

  //We are not displaying disabled clusters
  $clusters = Cluster::loadAllClusters(FALSE);
  $options = array();
  foreach ($clusters as $key => $cluster) {
    $options[$key] = $cluster->cluster_id;
  }
  $options[Cluster::getDefaultCluster()] = t('Default cluster: ' . Cluster::getDefaultCluster());
  $form['cluster_settings']['cluster'] = array(
    '#type' => 'select',
    '#title' => t('Cluster'),
    '#required' => TRUE,
    '#options' => $options,
    '#default_value' => $this->configuration['cluster_settings']['cluster'] ? $this->configuration['cluster_settings']['cluster'] : '',
    '#description' => t('Select the cluster you want to handle the connections.'),
  );
  return $form;
}