You are here

public function ExtlinkAdminSettingsForm::submitForm in External Links 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/ExtlinkAdminSettingsForm.php, line 296

Class

ExtlinkAdminSettingsForm
Displays the extlink settings form.

Namespace

Drupal\extlink\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $values = $form_state
    ->getValues();
  $whitelisted_domains = explode(PHP_EOL, $values['whitelisted_domains']);
  $whitelisted_domains = array_map('trim', $whitelisted_domains);
  $whitelisted_domains = array_filter($whitelisted_domains, function ($value) {
    return !empty($value);
  });
  $this
    ->config('extlink.settings')
    ->set('extlink_use_external_js_file', $values['extlink_use_external_js_file'])
    ->set('extlink_exclude_admin_routes', $values['extlink_exclude_admin_routes'])
    ->set('extlink_include', $values['extlink_include'])
    ->set('extlink_exclude', $values['extlink_exclude'])
    ->set('extlink_alert_text', $values['extlink_alert_text'])
    ->set('extlink_alert', $values['extlink_alert'])
    ->set('extlink_target', $values['extlink_target'])
    ->set('extlink_target_no_override', $values['extlink_target_no_override'])
    ->set('extlink_nofollow', $values['extlink_nofollow'])
    ->set('extlink_noreferrer', $values['extlink_noreferrer'])
    ->set('extlink_follow_no_override', $values['extlink_follow_no_override'])
    ->set('extlink_subdomains', $values['extlink_subdomains'])
    ->set('extlink_mailto_class', $values['extlink_mailto_class'])
    ->set('extlink_img_class', $values['extlink_img_class'])
    ->set('extlink_class', $values['extlink_class'])
    ->set('extlink_css_exclude', $values['extlink_css_exclude'])
    ->set('extlink_css_explicit', $values['extlink_css_explicit'])
    ->set('extlink_use_font_awesome', $values['extlink_use_font_awesome'])
    ->set('extlink_icon_placement', $values['extlink_icon_placement'])
    ->set('extlink_use_font_awesome', $values['extlink_use_font_awesome'])
    ->set('extlink_font_awesome_classes.links', $values['extlink_font_awesome_classes']['links'])
    ->set('extlink_font_awesome_classes.mailto', $values['extlink_font_awesome_classes']['mailto'])
    ->set('whitelisted_domains', $whitelisted_domains)
    ->save();
  parent::submitForm($form, $form_state);
}