You are here

public function FileHashConfigForm::submitForm in File Hash 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/FileHashConfigForm.php, line 78

Class

FileHashConfigForm
Implements the file hash config form.

Namespace

Drupal\filehash\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $original_algos = $this
    ->config('filehash.settings')
    ->get('algos');
  $this
    ->config('filehash.settings')
    ->set('algos', $form_state
    ->getValue('algos'))
    ->set('dedupe', $form_state
    ->getValue('dedupe'))
    ->save();

  // Invalidate the views cache if configured algorithms were modified.
  if ($this->moduleHandler
    ->moduleExists('views') && $form_state
    ->getValue('algos') != $original_algos) {
    views_invalidate_cache();
  }
  parent::submitForm($form, $form_state);
}