protected function SuggestionAdminForm::setStopwords in Autocomplete Search Suggestions 3.0.x
Same name and namespace in other branches
- 8.2 src/Form/SuggestionAdminForm.php \Drupal\suggestion\Form\SuggestionAdminForm::setStopwords()
- 8 src/Form/SuggestionAdminForm.php \Drupal\suggestion\Form\SuggestionAdminForm::setStopwords()
Process all the stopwords submitted.
Parameters
Drupal\Core\Form\FormStateInterface $form_state: A Drupal form state object.
1 call to SuggestionAdminForm::setStopwords()
- SuggestionAdminForm::submitForm in src/
Form/ SuggestionAdminForm.php - Submit function for the suggestion configuration form.
File
- src/
Form/ SuggestionAdminForm.php, line 316
Class
- SuggestionAdminForm
- Suggestion configuration form.
Namespace
Drupal\suggestion\FormCode
protected function setStopwords(FormStateInterface $form_state) {
$stopwords = [];
foreach (preg_split('/\\s*[\\n\\r]+\\s*/s', trim($form_state
->getValue('stopwords'))) as $txt) {
$stopwords += array_flip(preg_split('/\\s+/', SuggestionHelper::tokenize($txt, 2)));
}
$stopwords = array_fill_keys(array_keys($stopwords), 1);
ksort($stopwords);
$hash = Crypt::hashBase64(implode("\n", array_keys($stopwords)));
if ($hash != SuggestionHelper::getStops('hash')) {
SuggestionHelper::setStops('hash', $hash);
SuggestionHelper::setStops('stopwords', $stopwords);
SuggestionHelper::setConfig('synced', FALSE);
}
}