You are here

public function TikaServerExtractor::validateConfigurationForm in Search API attachments 8

Same name and namespace in other branches
  1. 9.0.x src/Plugin/search_api_attachments/TikaServerExtractor.php \Drupal\search_api_attachments\Plugin\search_api_attachments\TikaServerExtractor::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 form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().

Overrides TextExtractorPluginBase::validateConfigurationForm

File

src/Plugin/search_api_attachments/TikaServerExtractor.php, line 148

Class

TikaServerExtractor
Provides tika server extractor.

Namespace

Drupal\search_api_attachments\Plugin\search_api_attachments

Code

public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
  $values = $form_state
    ->getValues();
  if (isset($values['text_extractor_config']['port'])) {
    $port = $values['text_extractor_config']['port'];
    if (!is_numeric($port) || $port < 0 || $port > 65535) {
      $form_state
        ->setError($form['text_extractor_config']['port'], $this
        ->t('The port has to be an integer between 0 and 65535.'));
    }
  }
}