You are here

public function ConfigForm::submitForm in Insert 8.2

Same name and namespace in other branches
  1. 8 src/Form/ConfigForm.php \Drupal\insert\Form\ConfigForm::submitForm()

@inheritdoc

Overrides ConfigFormBase::submitForm

File

src/Form/ConfigForm.php, line 140

Class

ConfigForm

Namespace

Drupal\insert\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = $this
    ->config('insert.config');
  $config
    ->set('text_formats', array_keys(array_filter($form_state
    ->getValue('text_formats'), function ($value) {
    return !!$value;
  })));
  $config
    ->set('absolute', !!$form_state
    ->getValue('absolute'));
  $config
    ->set('file_field_images_enabled', !!$form_state
    ->getValue('file_field_images_enabled'));
  $config
    ->set('widgets.' . INSERT_TYPE_FILE, $this
    ->sanitize_array($form_state
    ->getValue('widgets__' . INSERT_TYPE_FILE)));
  $config
    ->set('widgets.' . INSERT_TYPE_IMAGE, $this
    ->sanitize_array($form_state
    ->getValue('widgets__' . INSERT_TYPE_IMAGE)));
  $config
    ->set('css_classes.' . INSERT_TYPE_FILE, $this
    ->sanitize_array($form_state
    ->getValue(INSERT_TYPE_FILE)));
  $config
    ->set('css_classes.' . INSERT_TYPE_IMAGE, $this
    ->sanitize_array($form_state
    ->getValue(INSERT_TYPE_IMAGE)));
  $config
    ->set('file_extensions.audio', $form_state
    ->getValue('audio'));
  $config
    ->set('file_extensions.video', $form_state
    ->getValue('video'));
  $config
    ->save();
  \Drupal::moduleHandler()
    ->invokeAll('insert_config_submit_form', [
    $form_state,
  ]);
  parent::submitForm($form, $form_state);
}