You are here

public function SimplesitemapCustomLinksForm::submitForm in Simple XML sitemap 8.2

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

Class

SimplesitemapCustomLinksForm
Class SimplesitemapCustomLinksForm @package Drupal\simple_sitemap\Form

Namespace

Drupal\simple_sitemap\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $custom_links = $this
    ->stringToCustomLinks($form_state
    ->getValue('custom_links'));
  $this->generator
    ->removeCustomLinks();
  foreach ($custom_links as $link_config) {
    $this->generator
      ->addCustomLink($link_config['path'], $link_config);
  }
  $this->generator
    ->saveSetting('custom_links_include_images', $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
      ->generateSitemap();
  }
}