public function SimplesitemapVariantsForm::submitForm in Simple XML sitemap 8.3
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/ SimplesitemapVariantsForm.php, line 87
Class
- SimplesitemapVariantsForm
- Class SimplesitemapVariantsForm @package Drupal\simple_sitemap\Form
Namespace
Drupal\simple_sitemap\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$manager = $this->generator
->getSitemapManager();
$new_variants = $this
->stringToVariants($form_state
->getValue('variants'));
$remove_variants = array_values(array_diff(array_keys($manager
->getSitemapVariants(NULL, FALSE)), array_keys($new_variants)));
$manager
->removeSitemapVariants($remove_variants);
$weight = 0;
foreach ($new_variants as $variant_name => $variant_definition) {
$manager
->addSitemapVariant($variant_name, $variant_definition + [
'weight' => $weight,
]);
$weight++;
}
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();
}
}