You are here

public function AuditFilesNotOnServer::submissionHandlerDeleteFromDb in Audit Files 8.2

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

Delete record to database.

File

src/Form/AuditFilesNotOnServer.php, line 259

Class

AuditFilesNotOnServer
Form for File not on server functionality.

Namespace

Drupal\auditfiles\Form

Code

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