You are here

public function XmlSitemapSettingsForm::submitForm in XML sitemap 8

Same name and namespace in other branches
  1. 2.x src/Form/XmlSitemapSettingsForm.php \Drupal\xmlsitemap\Form\XmlSitemapSettingsForm::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/XmlSitemapSettingsForm.php, line 295

Class

XmlSitemapSettingsForm
Configure xmlsitemap settings for this site.

Namespace

Drupal\xmlsitemap\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {

  // Save any changes to the frontpage link.
  $config = $this
    ->config('xmlsitemap.settings');

  // Remove button and internal Form API values from submitted values.
  $form_state
    ->cleanValues();
  $values = $form_state
    ->getValues();
  if (isset($form['frontpage'])) {
    $this->linkStorage
      ->save([
      'type' => 'frontpage',
      'id' => 0,
      'loc' => '/',
      'subtype' => '',
      'priority' => $values['frontpage_priority'],
      'changefreq' => $values['frontpage_changefreq'],
    ]);
  }
  $this->state
    ->set('xmlsitemap_developer_mode', $values['xmlsitemap_developer_mode']);
  $this->state
    ->set('xmlsitemap_base_url', $values['xmlsitemap_base_url']);
  unset($values['xmlsitemap_developer_mode']);
  unset($values['xmlsitemap_base_url']);
  foreach ($values as $key => $value) {
    $config
      ->set($key, $value);
  }
  $config
    ->save();
  parent::submitForm($form, $form_state);
}