You are here

public function MessageBannerSettingsForm::submitForm in Message Banner 8

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/MessageBannerSettingsForm.php, line 143

Class

MessageBannerSettingsForm
The message banner settings form.

Namespace

Drupal\message_banner\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $this
    ->config('message_banner.settings')
    ->set('banner_enabled', $form_state
    ->getValue('banner_enabled'))
    ->set('banner_enabled_on_admin_routes', $form_state
    ->getValue('banner_enabled_on_admin_routes'))
    ->set('banner_color', $form_state
    ->getValue('banner_color'))
    ->set('banner_text', $form_state
    ->getValue('banner_text'))
    ->set('banner_show_again_minutes', $form_state
    ->getValue('banner_show_again_minutes'))
    ->save();

  // Save the save time as a state value, so that config is not affected.
  $this->state
    ->set('banner_saved', time());
  return parent::submitForm($form, $form_state);
}