You are here

public function SearchApiSolrBackend::validateConfigurationForm in Search API Solr 8.3

Same name and namespace in other branches
  1. 8 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()

Throws

\Drupal\Component\Plugin\Exception\PluginException

\Drupal\search_api\SearchApiException

Overrides PluginFormTrait::validateConfigurationForm

File

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

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

  // @todo If any Solr Document datasource is selected, retrieve_data must be set.
  // @todo If solr_document is the only datasource, skip_schema_check must be set.
}