You are here

public function MediaDeleteForm::submitModalAjax in Media Directories 8

Same name and namespace in other branches
  1. 3.x modules/media_directories_ui/src/Form/MediaDeleteForm.php \Drupal\media_directories_ui\Form\MediaDeleteForm::submitModalAjax()
  2. 2.x modules/media_directories_ui/src/Form/MediaDeleteForm.php \Drupal\media_directories_ui\Form\MediaDeleteForm::submitModalAjax()

AJAX callback when the form is submitted.

File

modules/media_directories_ui/src/Form/MediaDeleteForm.php, line 107

Class

MediaDeleteForm
A form to delete medias.

Namespace

Drupal\media_directories_ui\Form

Code

public function submitModalAjax(array &$form, FormStateInterface $form_state) {
  $response = new AjaxResponse();
  foreach ($this->entities as $entity) {
    $entity
      ->delete();
  }
  $response
    ->addCommand(new CloseModalDialogCommand());
  $response
    ->addCommand(new LoadDirectoryContent());
  return $response;
}