You are here

public function Tokenizer::validateConfigurationForm in Search API 8

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 FieldsProcessorPluginBase::validateConfigurationForm

See also

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

File

src/Plugin/search_api/processor/Tokenizer.php, line 114

Class

Tokenizer
Splits text into individual words for searching.

Namespace

Drupal\search_api\Plugin\search_api\processor

Code

public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
  parent::validateConfigurationForm($form, $form_state);
  foreach ([
    'spaces',
    'ignored',
  ] as $field) {
    $field_value = $form_state
      ->getValue($field, '');
    $field_value = str_replace('/', '\\/', trim($field_value));
    if ($field_value !== '' && @preg_match('/[' . $field_value . ']+/u', '') === FALSE) {
      $form_state
        ->setError($form[$field], $form[$field]['#title'] . ': ' . $this
        ->t('The entered text is no valid PCRE character class.'));
    }
  }
}