You are here

public function NoReferrerSettingsForm::submitForm in No Referrer 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/NoReferrerSettingsForm.php, line 118

Class

NoReferrerSettingsForm
Implements a noreferrer Config form.

Namespace

Drupal\noreferrer\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $this
    ->config('noreferrer.settings')
    ->set('noopener', $form_state
    ->getValue('noopener'))
    ->set('noreferrer', $form_state
    ->getValue('noreferrer'))
    ->set('publish', $form_state
    ->getValue('publish'))
    ->set('subscribe_url', $form_state
    ->getValue('subscribe_url'))
    ->set('whitelisted_domains', $form_state
    ->getValue('whitelisted_domains'))
    ->save();
  if ($form_state
    ->getValue('publish')) {
    $this
      ->publish();
  }
  if ($url = $form_state
    ->getValue('subscribe_url')) {
    noreferrer_subscribe($url);
  }
  parent::submitForm($form, $form_state);
}