You are here

function ServiceAuditFilesUsedNotReferenced::_auditfiles_used_not_referenced_batch_delete_process_file in Audit Files 8

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 168
providing the service that used in 'used not referenced' functionality.

Class

ServiceAuditFilesUsedNotReferenced

Namespace

Drupal\auditfiles

Code

function _auditfiles_used_not_referenced_batch_delete_process_file($file_id) {
  $connection = Database::getConnection();
  $num_rows = $connection
    ->delete('file_usage')
    ->condition('fid', $file_id)
    ->execute();
  if (empty($num_rows)) {
    drupal_set_message(t('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,
    ]), 'warning');
  }
  else {
    drupal_set_message(t('Sucessfully deleted File ID : %fid from the file_usage table.', [
      '%fid' => $file_id,
    ]));
  }
}