You are here

public function ServiceAuditFilesNotOnServer::auditfilesNotOnServerBatchDeleteProcessFile in Audit Files 8.3

Same name and namespace in other branches
  1. 8.2 src/ServiceAuditFilesNotOnServer.php \Drupal\auditfiles\ServiceAuditFilesNotOnServer::auditfilesNotOnServerBatchDeleteProcessFile()
  2. 4.x src/ServiceAuditFilesNotOnServer.php \Drupal\auditfiles\ServiceAuditFilesNotOnServer::auditfilesNotOnServerBatchDeleteProcessFile()

Deletes the specified file from the database.

Parameters

int $file_id: The ID of the file to delete from the database.

File

src/ServiceAuditFilesNotOnServer.php, line 202

Class

ServiceAuditFilesNotOnServer
Providing the service that used in not in database functionality.

Namespace

Drupal\auditfiles

Code

public function auditfilesNotOnServerBatchDeleteProcessFile($file_id) {
  $connection = $this->connection;
  $num_rows = $connection
    ->delete('file_managed')
    ->condition('fid', $file_id)
    ->execute();
  if (empty($num_rows)) {
    $this
      ->messenger()
      ->addWarning($this->stringTranslation
      ->translate('There was a problem deleting the record with file ID %fid from the file_managed table. Check the logs for more information.', [
      '%fid' => $file_id,
    ]));
  }
  else {
    $this
      ->messenger()
      ->addStatus($this->stringTranslation
      ->translate('Sucessfully deleted File ID : %fid from the file_managed table.', [
      '%fid' => $file_id,
    ]));
  }
}