You are here

public function AuditFilesNotInDatabase::submissionHandlerDeleteRecord in Audit Files 8.3

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

Delete record from files.

File

src/Form/AuditFilesNotInDatabase.php, line 269

Class

AuditFilesNotInDatabase
Form for Not in database functionality.

Namespace

Drupal\auditfiles\Form

Code

public function submissionHandlerDeleteRecord(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'),
          'op' => 'delete',
          'confirm' => TRUE,
        ];
        $form_state
          ->setStorage($storage);
        $form_state
          ->setRebuild();
      }
    }
    if (!isset($storage)) {
      $this
        ->messenger()
        ->addError($this
        ->t('No items were selected to operate Delete.'));
    }
  }
}