You are here

public function ServiceAuditFilesUsedNotReferenced::auditfilesUsedNotReferencedBatchDeleteProcessFile in Audit Files 8.2

Same name and namespace in other branches
  1. 8.3 src/ServiceAuditFilesUsedNotReferenced.php \Drupal\auditfiles\ServiceAuditFilesUsedNotReferenced::auditfilesUsedNotReferencedBatchDeleteProcessFile()
  2. 4.x src/ServiceAuditFilesUsedNotReferenced.php \Drupal\auditfiles\ServiceAuditFilesUsedNotReferenced::auditfilesUsedNotReferencedBatchDeleteProcessFile()

Deletes the specified file from the file_usage table.

Parameters

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

File

src/ServiceAuditFilesUsedNotReferenced.php, line 211

Class

ServiceAuditFilesUsedNotReferenced
List all methods used in files used not managed functionality.

Namespace

Drupal\auditfiles

Code

public function auditfilesUsedNotReferencedBatchDeleteProcessFile($file_id) {
  $connection = $this->connection;
  $num_rows = $connection
    ->delete('file_usage')
    ->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_usage 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_usage table.', [
      '%fid' => $file_id,
    ]));
  }
}