You are here

public function AbstractSearchApiSolrMultilingualBackend::buildConfigurationForm in Search API Solr 8.2

Form constructor.

Plugin forms are embedded in other forms. In order to know where the plugin form is located in the parent form, #parents and #array_parents must be known, but these are not available during the initial build phase. In order to have these properties available when building the plugin form's elements, let this method return a form element that has a #process callback and build the rest of the form in the callback. By the time the callback is executed, the element's #parents and #array_parents properties will have been set by the form API. For more documentation on #parents and #array_parents, see \Drupal\Core\Render\Element\FormElement.

Parameters

array $form: An associative array containing the initial structure of the plugin form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().

Return value

array The form structure.

Overrides SearchApiSolrBackend::buildConfigurationForm

File

src/Plugin/search_api/backend/AbstractSearchApiSolrMultilingualBackend.php, line 63

Class

AbstractSearchApiSolrMultilingualBackend
A abstract base class for all multilingual Solr Search API backends.

Namespace

Drupal\search_api_solr\Plugin\search_api\backend

Code

public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
  $form = parent::buildConfigurationForm($form, $form_state);
  $form['multilingual'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('Multilingual'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  ];
  $form['multilingual']['sasm_limit_search_page_to_content_language'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Limit to current content language.'),
    '#description' => $this
      ->t('Limit all search results for custom queries or search pages not managed by Views to current content language if no language is specified in the query.'),
    '#default_value' => isset($this->configuration['sasm_limit_search_page_to_content_language']) ? $this->configuration['sasm_limit_search_page_to_content_language'] : FALSE,
  ];
  $form['multilingual']['sasm_search_page_include_language_independent'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Include language independent content in search results.'),
    '#description' => $this
      ->t('This option will include content without a language assigned in the results of custom queries or search pages not managed by Views. For example, if you search for English content, but have an article with languague of "undefined", you will see those results as well. If you disable this option, you will only see content that matches the language.'),
    '#default_value' => isset($this->configuration['sasm_search_page_include_language_independent']) ? $this->configuration['sasm_search_page_include_language_independent'] : FALSE,
  ];
  $form['multilingual']['sasm_language_unspecific_fallback_on_schema_issues'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Use language fallbacks.'),
    '#description' => $this
      ->t('This option is suitable for two use-cases. First, if you have languages like "de" and "de-at", both could be handled by a shared configuration for "de". Second, new languages will be handled by language-unspecific fallback configuration until the schema gets updated on your Solr server.'),
    '#default_value' => isset($this->configuration['sasm_language_unspecific_fallback_on_schema_issues']) ? $this->configuration['sasm_language_unspecific_fallback_on_schema_issues'] : TRUE,
  ];
  return $form;
}