You are here

public function LinkCheckerAdminSettingsForm::submitForm in Link checker 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/LinkCheckerAdminSettingsForm.php, line 455

Class

LinkCheckerAdminSettingsForm
Configure Linkchecker settings for this site.

Namespace

Drupal\linkchecker\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = $this
    ->config('linkchecker.settings');

  // @todo: Move it to setting save hook.
  if ((int) $config
    ->get('check.connections_max') != (int) $form_state
    ->getValue('linkchecker_check_connections_max')) {
    $this->linkCheckerService
      ->queueLinks(TRUE);
  }
  $config
    ->set('scan_blocks', $form_state
    ->getValue('linkchecker_scan_blocks'))
    ->set('check_links_types', $form_state
    ->getValue('linkchecker_check_links_types'))
    ->set('default_url_scheme', $form_state
    ->getValue('default_url_scheme'))
    ->set('base_path', $form_state
    ->getValue('base_path'))
    ->set('extract.from_a', $form_state
    ->getValue('linkchecker_extract_from_a'))
    ->set('extract.from_audio', $form_state
    ->getValue('linkchecker_extract_from_audio'))
    ->set('extract.from_embed', $form_state
    ->getValue('linkchecker_extract_from_embed'))
    ->set('extract.from_iframe', $form_state
    ->getValue('linkchecker_extract_from_iframe'))
    ->set('extract.from_img', $form_state
    ->getValue('linkchecker_extract_from_img'))
    ->set('extract.from_object', $form_state
    ->getValue('linkchecker_extract_from_object'))
    ->set('extract.from_video', $form_state
    ->getValue('linkchecker_extract_from_video'))
    ->set('extract.filter_blacklist', $form_state
    ->getValue('linkchecker_filter_blacklist'))
    ->set('check.connections_max', $form_state
    ->getValue('linkchecker_check_connections_max'))
    ->set('check.disable_link_check_for_urls', $form_state
    ->getValue('linkchecker_disable_link_check_for_urls'))
    ->set('check.library', $form_state
    ->getValue('linkchecker_check_library'))
    ->set('check.interval', $form_state
    ->getValue('linkchecker_check_interval'))
    ->set('check.useragent', $form_state
    ->getValue('linkchecker_check_useragent'))
    ->set('error.action_status_code_301', $form_state
    ->getValue('linkchecker_action_status_code_301'))
    ->set('error.action_status_code_404', $form_state
    ->getValue('linkchecker_action_status_code_404'))
    ->set('error.ignore_response_codes', $form_state
    ->getValue('linkchecker_ignore_response_codes'))
    ->set('error.impersonate_account', $form_state
    ->getValue('linkchecker_impersonate_account'))
    ->set('logging.level', $form_state
    ->getValue('linkchecker_logging_level'))
    ->save();
  parent::submitForm($form, $form_state);
}