You are here

public function XmlSitemapEnginesSettingsForm::submitForm in XML sitemap 8

Same name and namespace in other branches
  1. 2.x xmlsitemap_engines/src/Form/XmlSitemapEnginesSettingsForm.php \Drupal\xmlsitemap_engines\Form\XmlSitemapEnginesSettingsForm::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

xmlsitemap_engines/src/Form/XmlSitemapEnginesSettingsForm.php, line 161

Class

XmlSitemapEnginesSettingsForm
Configure xmlsitemap engines settings for this site.

Namespace

Drupal\xmlsitemap_engines\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  parent::submitForm($form, $form_state);
  $state_variables = xmlsitemap_engines_state_variables();
  $keys = [
    'engines',
    'minimum_lifetime',
    'xmlsitemap_engines_submit_updated',
    'custom_urls',
  ];
  $config = $this
    ->config('xmlsitemap_engines.settings');
  $values = $form_state
    ->getValues();
  foreach ($keys as $key) {
    if (isset($state_variables[$key])) {
      $this->state
        ->set($key, $values[$key]);
    }
    else {
      $config
        ->set($key, $values[$key]);
    }
  }
  $config
    ->save();
}