You are here

public function AuditFilesReferencedNotUsed::submissionHandlerDeleteFromFileUsage in Audit Files 8

Same name and namespace in other branches
  1. 8.3 src/Form/AuditFilesReferencedNotUsed.php \Drupal\auditfiles\Form\AuditFilesReferencedNotUsed::submissionHandlerDeleteFromFileUsage()
  2. 8.2 src/Form/AuditFilesReferencedNotUsed.php \Drupal\auditfiles\Form\AuditFilesReferencedNotUsed::submissionHandlerDeleteFromFileUsage()
  3. 4.x src/Form/AuditFilesReferencedNotUsed.php \Drupal\auditfiles\Form\AuditFilesReferencedNotUsed::submissionHandlerDeleteFromFileUsage()

Submit form.

File

src/Form/AuditFilesReferencedNotUsed.php, line 215

Class

AuditFilesReferencedNotUsed

Namespace

Drupal\auditfiles\Form

Code

public function submissionHandlerDeleteFromFileUsage(array &$form, FormStateInterface $form_state) {
  if (!empty($form_state
    ->getValue('files'))) {
    foreach ($form_state
      ->getValue('files') as $file_id) {
      if (!empty($file_id)) {
        $storage = [
          'files' => $form_state
            ->getValue('files'),
          'confirm' => TRUE,
          'op' => 'delete',
        ];
        $form_state
          ->setStorage($storage);
        $form_state
          ->setRebuild();
      }
    }
    if (!isset($storage)) {
      drupal_set_message($this
        ->t('No items were selected to operate on.'), 'error');
    }
  }
}