You are here

public function ServiceAuditFilesReferencedNotUsed::auditfilesReferencedNotUsedBatchDeleteProcessFile in Audit Files 8.2

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

Deletes the specified file from the database.

Parameters

string $reference_id: The ID for keeping track of the reference.

File

src/ServiceAuditFilesReferencedNotUsed.php, line 330

Class

ServiceAuditFilesReferencedNotUsed
List all methods used in referenced not used functionality.

Namespace

Drupal\auditfiles

Code

public function auditfilesReferencedNotUsedBatchDeleteProcessFile($reference_id) {
  $reference_id_parts = explode('.', $reference_id);
  $connection = $this->connection;
  $num_rows = $connection
    ->delete($reference_id_parts[0])
    ->condition($reference_id_parts[1], $reference_id_parts[4])
    ->execute();
  if (empty($num_rows)) {
    $this
      ->messenger()
      ->addWarning($this->stringTranslation
      ->translate('There was a problem deleting the reference to file ID %fid in the %entity_type with ID %eid. Check the logs for more information.', [
      '%fid' => $reference_id_parts[4],
      '%entity_type' => $reference_id_parts[3],
      '%eid' => $reference_id_parts[2],
    ]));
  }
  else {
    $this
      ->messenger()
      ->addStatus($this->stringTranslation
      ->translate('file ID %fid  deleted successfully.', [
      '%fid' => $reference_id_parts[4],
    ]));
  }
}