public function FileDeleteMultiple::submitForm in Panopoly 8.2
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
- modules/
panopoly/ panopoly_media/ src/ Form/ FileDeleteMultiple.php, line 160
Class
- FileDeleteMultiple
- Provides a file deletion confirmation form.
Namespace
Drupal\panopoly_media\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
if ($form_state
->getValue('confirm') && !empty($this->fileInfo)) {
$count = 0;
$files = $this->storage
->loadMultiple($this->fileInfo);
foreach ($this->fileInfo as $fid) {
if (empty($files[$fid])) {
break;
}
$files[$fid]
->delete();
$count++;
}
$this
->logger('file')
->notice('Deleted @count files.', [
'@count' => $count,
]);
if ($count) {
$this->messenger
->addMessage($this
->formatPlural($count, 'Deleted 1 file.', 'Deleted @count files.'));
}
}
$form_state
->setRedirectUrl($this
->getCancelUrl());
}