You are here

public function WebformAdminConfigLibrariesForm::submitForm in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Form/AdminConfig/WebformAdminConfigLibrariesForm.php \Drupal\webform\Form\AdminConfig\WebformAdminConfigLibrariesForm::submitForm()

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 WebformAdminConfigBaseForm::submitForm

File

src/Form/AdminConfig/WebformAdminConfigLibrariesForm.php, line 215

Class

WebformAdminConfigLibrariesForm
Configure webform admin settings for libraries.

Namespace

Drupal\webform\Form\AdminConfig

Code

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

  // Convert list of included types to excluded types.
  $excluded_libraries = array_diff($this->libraries, array_filter($form_state
    ->getValue('excluded_libraries')));
  ksort($excluded_libraries);

  // Note: Must store a simple array of libraries because library names
  // may contain periods, which is not supported by Drupal's
  // config management.
  $excluded_libraries = array_keys($excluded_libraries);

  // Update config and submit form.
  $config = $this
    ->config('webform.settings');
  $config
    ->set('assets', $form_state
    ->getValue('assets'));
  $config
    ->set('libraries.excluded_libraries', $excluded_libraries);
  parent::submitForm($form, $form_state);

  // Reset libraries cached.
  // @see webform_library_info_build()
  \Drupal::service('library.discovery')
    ->clearCachedDefinitions();
}