You are here

public function SimplesitemapSettingsForm::submitForm in Simple XML sitemap 8.2

Same name and namespace in other branches
  1. 8.3 src/Form/SimplesitemapSettingsForm.php \Drupal\simple_sitemap\Form\SimplesitemapSettingsForm::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/SimplesitemapSettingsForm.php, line 167

Class

SimplesitemapSettingsForm
Class SimplesitemapSettingsForm @package Drupal\simple_sitemap\Form

Namespace

Drupal\simple_sitemap\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  foreach ([
    'max_links',
    'cron_generate',
    'cron_generate_interval',
    'remove_duplicates',
    'skip_untranslated',
    'batch_process_limit',
    'base_url',
  ] as $setting_name) {
    $this->generator
      ->saveSetting($setting_name, $form_state
      ->getValue($setting_name));
  }
  $this->generator
    ->saveSetting('excluded_languages', array_filter($form_state
    ->getValue('excluded_languages')));
  parent::submitForm($form, $form_state);

  // Regenerate sitemaps according to user setting.
  if ($form_state
    ->getValue('simple_sitemap_regenerate_now')) {
    $this->generator
      ->generateSitemap();
  }
}