You are here

public function SettingsForm::submitForm in File Upload Secure Validator 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/SettingsForm.php, line 81

Class

SettingsForm
A configuration settings form.

Namespace

Drupal\file_upload_secure_validator\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  parent::submitForm($form, $form_state);

  // Provides backward compatibility.
  $options = [];
  if (defined('CsvEncoder::NO_HEADERS_KEY')) {
    $options[CsvEncoder::NO_HEADERS_KEY] = TRUE;
  }
  $mimeTypesGroups = (new CsvEncoder())
    ->decode($form_state
    ->getValue('mime_types_equivalence_groups'), 'csv', $options);
  $this
    ->config('file_upload_secure_validator.settings')
    ->set('mime_types_equivalence_groups', $mimeTypesGroups)
    ->save();
}