You are here

public function SearchApiSolrBackend::validateConfigurationForm 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::validateConfigurationForm()
  2. 8 src/Plugin/search_api/backend/SearchApiSolrBackend.php \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend::validateConfigurationForm()
  3. 4.x src/Plugin/search_api/backend/SearchApiSolrBackend.php \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend::validateConfigurationForm()

Throws

\Drupal\Component\Plugin\Exception\PluginException

\Drupal\search_api\SearchApiException

Overrides PluginFormTrait::validateConfigurationForm

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

File

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

Class

SearchApiSolrBackend
Apache Solr backend for search api.

Namespace

Drupal\search_api_solr\Plugin\search_api\backend

Code

public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {

  // Check if the Solr connector plugin changed.
  if ($form_state
    ->getValue('connector') != $form_state
    ->get('connector')) {
    $new_connector = $this->solrConnectorPluginManager
      ->createInstance($form_state
      ->getValue('connector'));
    if ($new_connector instanceof PluginFormInterface) {
      $form_state
        ->setRebuild();
    }
    else {
      $form_state
        ->setError($form['connector'], $this
        ->t('The connector could not be activated.'));
    }
  }
  else {
    $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
        ->validateConfigurationForm($form['connector_config'], $connector_form_state);
    }
    else {
      $form_state
        ->setError($form['connector'], $this
        ->t('The connector could not be activated.'));
    }
  }
}