public function SitemapSettingsForm::submitForm in Site map 8
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 322
Class
- SitemapSettingsForm
- Provides a configuration form for sitemap.
Namespace
Drupal\site_map\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = $this->configFactory
->getEditable('site_map.settings');
$keys = array(
'page_title',
array(
'message',
'value',
),
array(
'message',
'format',
),
'show_front',
'show_titles',
'show_menus',
'show_menus_hidden',
'show_vocabularies',
'show_description',
'show_count',
'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';
}
if ($this->moduleHandler
->moduleExists('faq')) {
$keys[] = 'show_faq';
}
// Save config.
foreach ($keys as $key) {
if ($form_state
->hasValue($key)) {
$config
->set(is_string($key) ? $key : implode('.', $key), $form_state
->getValue($key));
}
}
$config
->save();
parent::submitForm($form, $form_state);
}