You are here

function ServiceAuditFilesReferencedNotUsed::_auditfiles_referenced_not_used_batch_delete_process_file in Audit Files 8

Deletes the specified file from the database.

Parameters

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

File

src/ServiceAuditFilesReferencedNotUsed.php, line 267
providing the service that used in 'referenced not used' functionality.

Class

ServiceAuditFilesReferencedNotUsed

Namespace

Drupal\auditfiles

Code

function _auditfiles_referenced_not_used_batch_delete_process_file($reference_id) {
  $reference_id_parts = explode('.', $reference_id);
  $connection = Database::getConnection();
  $num_rows = $connection
    ->delete($reference_id_parts[0])
    ->condition($reference_id_parts[1], $reference_id_parts[4])
    ->execute();
  if (empty($num_rows)) {
    drupal_set_message(t('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],
    ]), 'warning');
  }
  else {
    drupal_set_message(t('file ID %fid  deleted successfully.', [
      '%fid' => $reference_id_parts[4],
    ]));
  }
}