You are here

public function JavascriptCoreLibrariesDeleteForm::submitForm in JavaScript Libraries Manager 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 FormInterface::submitForm

File

src/Form/JavascriptCoreLibrariesDeleteForm.php, line 64
Contains \Drupal\javascript_libraries\Form\JavascriptLibrariesDeleteForm.

Class

JavascriptCoreLibrariesDeleteForm

Namespace

Drupal\javascript_libraries\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $custom = \Drupal::config('javascript_libraries.settings')
    ->get('javascript_libraries_core_libraries');
  $library_id = $this->id;
  unset($custom[$library_id]);
  \Drupal::configFactory()
    ->getEditable('javascript_libraries.settings')
    ->set('javascript_libraries_core_libraries', $custom)
    ->save();
  drupal_set_message("The library has been deleted succesfully");
  return $form_state
    ->setRedirect('javascript_libraries.default_form');
}