public function SitemapSettingsForm::submitForm in Sitemap 8
Same name and namespace in other branches
- 8.2 src/Form/SitemapSettingsForm.php \Drupal\sitemap\Form\SitemapSettingsForm::submitForm()
- 2.0.x src/Form/SitemapSettingsForm.php \Drupal\sitemap\Form\SitemapSettingsForm::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/ SitemapSettingsForm.php, line 351
Class
- SitemapSettingsForm
- Provides a configuration form for sitemap.
Namespace
Drupal\sitemap\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = $this->configFactory
->getEditable('sitemap.settings');
$keys = [
'page_title',
[
'message',
'value',
],
[
'message',
'format',
],
'show_front',
'show_titles',
'show_menus',
'show_menus_hidden',
'show_vocabularies',
'show_description',
'show_count',
'vocabulary_show_links',
'vocabulary_depth',
'term_threshold',
'forum_threshold',
'rss_front',
'show_rss_links',
'rss_taxonomy',
'css',
'order',
];
if ($this->moduleHandler
->moduleExists('book')) {
$keys[] = 'show_books';
$keys[] = 'books_expanded';
}
// Save config.
foreach ($keys as $key) {
if ($form_state
->hasValue($key)) {
if ($key == 'order') {
$order = $form_state
->getValue($key);
asort($order);
$config
->set(is_string($key) ? $key : implode('.', $key), $order);
}
else {
$config
->set(is_string($key) ? $key : implode('.', $key), $form_state
->getValue($key));
}
}
}
$config
->save();
drupal_flush_all_caches();
parent::submitForm($form, $form_state);
}