You are here

function ServiceAuditFilesUsedNotManaged::_auditfiles_used_not_managed_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/ServiceAuditFilesUsedNotManaged.php, line 102
providing the service that used in 'used not managed' functionality.

Class

ServiceAuditFilesUsedNotManaged

Namespace

Drupal\auditfiles

Code

function _auditfiles_used_not_managed_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_usages table.', [
      '%fid' => $file_id,
    ]));
  }
}