public function GeshiFilterLanguagesForm::submitForm in GeSHi Filter for syntax highlighting 8
Same name and namespace in other branches
- 8.2 src/Form/GeshiFilterLanguagesForm.php \Drupal\geshifilter\Form\GeshiFilterLanguagesForm::submitForm()
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides ConfigFormBase::submitForm
File
- src/
Form/ GeshiFilterLanguagesForm.php, line 116
Class
- GeshiFilterLanguagesForm
- Form used to set enable/disabled for languages.
Namespace
Drupal\geshifilter\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = $this
->config('geshifilter.settings');
$languages = $form_state
->getValue('language');
foreach ($languages as $key => $value) {
if ($value["enabled"] == FALSE) {
// Remove all disabled languages from config.
$config
->clear("language.{$key}.enabled");
}
else {
// Set only the enabled languages.
$config
->set("language.{$key}.enabled", TRUE);
}
if ($value["tags"] == '') {
// Remove all languages without tags from config.
$config
->clear("language.{$key}.tags");
}
else {
// Set only languages with tags.
$config
->set("language.{$key}.tags", $value["tags"]);
}
}
$config
->save();
// Regenerate language_css.
if ($config
->get('css_mode', GeshiFilter::CSS_INLINE) == GeshiFilter::CSS_CLASSES_AUTOMATIC) {
GeshiFilterCss::generateLanguagesCssFile();
}
Cache::invalidateTags([
'geshifilter',
]);
}