You are here

public function SettingsPopup::submitForm in General Data Protection Regulation Compliance 8

Implements a form submit handler.

Overrides ConfigFormBase::submitForm

File

src/Form/SettingsPopup.php, line 155

Class

SettingsPopup
Implements the form controller.

Namespace

Drupal\gdpr_compliance\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = $this
    ->config('gdpr_compliance.settings');
  $popup_color = $form_state
    ->getValue('popup-color');
  if ($popup_hex = $this
    ->tryHex($form_state
    ->getValue('popup-hex'))) {
    $popup_color = $popup_hex;
  }
  $button_color = $form_state
    ->getValue('button-color');
  if ($button_hex = $this
    ->tryHex($form_state
    ->getValue('button-hex'))) {
    $button_color = $button_hex;
  }
  $config
    ->set('popup-users', $form_state
    ->getValue('popup-users'))
    ->set('popup-guests', $form_state
    ->getValue('popup-guests'))
    ->set('popup-position', $form_state
    ->getValue('popup-position'))
    ->set('popup-morelink', $form_state
    ->getValue('popup-morelink'))
    ->set('popup-text-cookies', $form_state
    ->getValue('popup-text-cookies'))
    ->set('popup-text-analytics', $form_state
    ->getValue('popup-text-analytics'))
    ->set('popup-btn-agree', $form_state
    ->getValue('popup-btn-agree'))
    ->set('popup-btn-findmore', $form_state
    ->getValue('popup-btn-findmore'))
    ->set('popup-custom-color', $form_state
    ->getValue('popup-custom-color'))
    ->set('popup-color', $popup_color)
    ->set('popup-text', $this
    ->getColorContrastInverse($popup_color))
    ->set('button-color', $button_color)
    ->set('button-text', $this
    ->getColorContrastInverse($button_color))
    ->save();
}