public function CustomLinksForm::submitForm in Simple XML sitemap 4.x
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/ CustomLinksForm.php, line 159
Class
- CustomLinksForm
- Class CustomLinksForm
Namespace
Drupal\simple_sitemap\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->generator
->setVariants(TRUE)
->customLinkManager()
->remove();
if (!empty($variants = $form_state
->getValue('variants')) && !empty($links = $form_state
->getValue('custom_links'))) {
$this->generator
->setVariants(array_values($variants));
foreach ($this
->stringToCustomLinks($links) as $link_config) {
$this->generator
->customLinkManager()
->add($link_config['path'], $link_config);
}
}
$this->settings
->save('custom_links_include_images', (bool) $form_state
->getValue('include_images'));
parent::submitForm($form, $form_state);
// Regenerate sitemaps according to user setting.
if ($form_state
->getValue('simple_sitemap_regenerate_now')) {
$this->generator
->setVariants(TRUE)
->rebuildQueue()
->generateSitemap();
}
}