Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function validateConfigurationForm(array &$form, FormStateInterface $form_state)
 {
     parent::validateConfigurationForm($form, $form_state);
     $spaces = str_replace('/', '\\/', trim($form_state->getValues()['spaces']));
     if ($spaces !== '' && @preg_match('/(' . $spaces . ')+/u', '') === FALSE) {
         $form_state->setError($form['spaces'], $form['spaces']['#title'] . ': ' . $this->t('The entered text is no valid regular expression.'));
     }
 }
Esempio n. 2
0
 /**
  * {@inheritdoc}
  */
 public function validateConfigurationForm(array &$form, FormStateInterface $form_state)
 {
     parent::validateConfigurationForm($form, $form_state);
     $ignorable = str_replace('/', '\\/', $form_state->getValues()['ignorable']);
     if (@preg_match('/(' . $ignorable . ')+/u', '') === FALSE) {
         $el = $form['ignorable'];
         $form_state->setError($el, $el['#title'] . ': ' . $this->t('The entered text is no valid regular expression.'));
     }
 }
 /**
  * {@inheritdoc}
  */
 public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition)
 {
     /** @var static $processor */
     $processor = parent::create($container, $configuration, $plugin_id, $plugin_definition);
     /** @var \Drupal\Component\Transliteration\TransliterationInterface $transliterator */
     $transliterator = $container->get('transliteration');
     $processor->setTransliterator($transliterator);
     /** @var \Drupal\Core\Language\LanguageManagerInterface $language_manager */
     $language_manager = $container->get('language_manager');
     $processor->setLangcode($language_manager->getDefaultLanguage()->getId());
     return $processor;
 }
Esempio n. 4
0
 /**
  * {@inheritdoc}
  */
 public function validateConfigurationForm(array &$form, FormStateInterface $form_state)
 {
     parent::validateConfigurationForm($form, $form_state);
     $tags = trim($form_state->getValue('tags'));
     if (!$tags) {
         $form_state->setValue('tags', array());
         return;
     }
     $errors = array();
     try {
         $parser = new Parser();
         $tags = $parser->parse($tags);
         if (!is_array($tags)) {
             $errors[] = $this->t('Tags is not a valid YAML map. See @link for information on how to write correctly formed YAML.', array('@link' => 'http://yaml.org'));
             $tags = array();
         }
     } catch (ParseException $exception) {
         $errors[] = $this->t('Tags is not valid YAML. See @link for information on how to write correctly formed YAML.', array('@link' => 'http://yaml.org'));
         $tags = array();
     }
     foreach ($tags as $key => $value) {
         $tag = "<{$key}>";
         if (is_array($value)) {
             $errors[] = $this->t("Boost value for tag @tag can't be an array.", array('@tag' => $tag));
         } elseif (!is_numeric($value)) {
             $errors[] = $this->t("Boost value for tag @tag must be numeric.", array('@tag' => $tag));
         } elseif ($value < 0) {
             $errors[] = $this->t('Boost value for tag @tag must be non-negative.', array('@tag' => $tag));
         } elseif ($value == 1) {
             unset($tags[$key]);
         } else {
             $tags[$key] = (double) $value;
         }
     }
     $form_state->setValue('tags', $tags);
     if ($errors) {
         $form_state->setError($form['tags'], implode("<br />\n", $errors));
     }
 }
Esempio n. 5
0
 /**
  * {@inheritdoc}
  */
 public function preprocessSearchQuery(QueryInterface $query)
 {
     $this->ignored = array();
     parent::preprocessSearchQuery($query);
 }
 /**
  * {@inheritdoc}
  */
 protected function processConditionValue(&$value)
 {
     if (isset($this->methodOverrides[__FUNCTION__])) {
         $this->methodOverrides[__FUNCTION__]($value);
         return;
     }
     parent::processConditionValue($value);
 }