You are here

public function SearchApiSolrBackend::submitConfigurationForm in Search API Solr 8.2

Same name and namespace in other branches
  1. 8.3 src/Plugin/search_api/backend/SearchApiSolrBackend.php \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend::submitConfigurationForm()
  2. 8 src/Plugin/search_api/backend/SearchApiSolrBackend.php \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend::submitConfigurationForm()
  3. 4.x src/Plugin/search_api/backend/SearchApiSolrBackend.php \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend::submitConfigurationForm()

Throws

\Drupal\search_api\SearchApiException

Overrides PluginFormInterface::submitConfigurationForm

1 call to SearchApiSolrBackend::submitConfigurationForm()
AbstractSearchApiSolrMultilingualBackend::submitConfigurationForm in src/Plugin/search_api/backend/AbstractSearchApiSolrMultilingualBackend.php
Form submission handler.
1 method overrides SearchApiSolrBackend::submitConfigurationForm()
AbstractSearchApiSolrMultilingualBackend::submitConfigurationForm in src/Plugin/search_api/backend/AbstractSearchApiSolrMultilingualBackend.php
Form submission handler.

File

src/Plugin/search_api/backend/SearchApiSolrBackend.php, line 380

Class

SearchApiSolrBackend
Apache Solr backend for search api.

Namespace

Drupal\search_api_solr\Plugin\search_api\backend

Code

public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
  $this->configuration['connector'] = $form_state
    ->get('connector');
  $connector = $this
    ->getSolrConnector();
  if ($connector instanceof PluginFormInterface) {
    $connector_form_state = SubformState::createForSubform($form['connector_config'], $form, $form_state);
    $connector
      ->submitConfigurationForm($form['connector_config'], $connector_form_state);
  }
  $values = $form_state
    ->getValues();

  // Since the form is nested into another, we can't simply use #parents for
  // doing this array restructuring magic. (At least not without creating an
  // unnecessary dependency on internal implementation.)
  $values += $values['advanced'];
  $values += $values['multisite'];

  // Highlighting retrieved data only makes sense when we retrieve data from
  // the Solr backend.
  $values['highlight_data'] &= $values['retrieve_data'];
  foreach ($values as $key => $value) {
    $form_state
      ->setValue($key, $value);
  }

  // Clean-up the form to avoid redundant entries in the stored configuration.
  $form_state
    ->unsetValue('advanced');
  $form_state
    ->unsetValue('multisite');

  // The server description is a #type item element, which means it has a
  // value, do not save it.
  $form_state
    ->unsetValue('server_description');
  $this
    ->traitSubmitConfigurationForm($form, $form_state);

  // Delete cached endpoint data.
  \Drupal::state()
    ->delete('search_api_solr.endpoint.data');
}