You are here

public function SearchApiSolrBackend::validateConfigurationForm in Search API Solr 8

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

Form validation handler.

Parameters

array $form: An associative array containing the structure of the plugin form as built by static::buildConfigurationForm().

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the complete form.

Overrides PluginFormTrait::validateConfigurationForm

See also

\Drupal\Core\Plugin\PluginFormInterface::validateConfigurationForm()

File

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

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.'));
    }
  }
}