You are here

public function HttpblConfigForm::submitForm in http:BL 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/HttpblConfigForm.php, line 313

Class

HttpblConfigForm
Defines a form that configures httpbl settings.

Namespace

Drupal\httpbl\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  parent::submitForm($form, $form_state);
  $values = $form_state
    ->getValues();
  $this
    ->config('httpbl.settings')
    ->set('httpbl_accesskey', $values['httpbl_accesskey'])
    ->set('httpbl_check', (int) $values['httpbl_check'])
    ->set('httpbl_footer', $values['httpbl_footer'])
    ->set('httpbl_link', $values['httpbl_link'])
    ->set('httpbl_word', $values['httpbl_word'])
    ->set('httpbl_log', (int) $values['httpbl_log'])
    ->set('httpbl_stats', (int) $values['httpbl_stats'])
    ->set('httpbl_storage', (int) $values['httpbl_storage'])
    ->set('httpbl_black_threshold', $values['httpbl_black_threshold'])
    ->set('httpbl_message_black', $values['httpbl_message_black'])
    ->set('httpbl_grey_threshold', $values['httpbl_grey_threshold'])
    ->set('httpbl_message_grey', $values['httpbl_message_grey'])
    ->set('httpbl_safe_offset', $values['httpbl_safe_offset'])
    ->set('httpbl_greylist_offset', $values['httpbl_greylist_offset'])
    ->set('httpbl_blacklist_offset', $values['httpbl_blacklist_offset'])
    ->save();

  // Use the form values to set some run-time variables.
  \Drupal::state()
    ->set('httpbl.accesskey', $values['httpbl_accesskey']);
  \Drupal::state()
    ->set('httpbl.check', (int) $values['httpbl_check']);
  \Drupal::state()
    ->set('httpbl.footer', $values['httpbl_footer']);
  \Drupal::state()
    ->set('httpbl.link', $values['httpbl_link']);
  \Drupal::state()
    ->set('httpbl.word', $values['httpbl_word']);
  \Drupal::state()
    ->set('httpbl.log', (int) $values['httpbl_log']);
  \Drupal::state()
    ->set('httpbl.stats', (int) $values['httpbl_stats']);
  \Drupal::state()
    ->set('httpbl.storage', (int) $values['httpbl_storage']);
  \Drupal::state()
    ->set('httpbl.black_threshold', $values['httpbl_black_threshold']);
  \Drupal::state()
    ->set('httpbl.message_black', $values['httpbl_message_black']);
  \Drupal::state()
    ->set('httpbl.grey_threshold', $values['httpbl_grey_threshold']);
  \Drupal::state()
    ->set('httpbl.message_grey', $values['httpbl_message_grey']);
  \Drupal::state()
    ->set('httpbl.safe_offset', $values['httpbl_safe_offset']);
  \Drupal::state()
    ->set('httpbl.greylist_offset', $values['httpbl_greylist_offset']);
  \Drupal::state()
    ->set('httpbl.blacklist_offset', $values['httpbl_blacklist_offset']);

  //drupal_flush_all_caches();
}