You are here

function ServiceAuditFilesManagedNotUsed::_auditfiles_managed_not_used_batch_delete_process_file in Audit Files 8

Deletes the specified file from the file_managed table.

Parameters

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

File

src/ServiceAuditFilesManagedNotUsed.php, line 127
providing the service that used in 'managed not used' functionality.

Class

ServiceAuditFilesManagedNotUsed

Namespace

Drupal\auditfiles

Code

function _auditfiles_managed_not_used_batch_delete_process_file($file_id) {
  $connection = Database::getConnection();
  $num_rows = $connection
    ->delete('file_managed')
    ->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_managed table. Check the logs for more information.', [
      '%fid' => $file_id,
    ]), 'warning');
  }
  else {
    drupal_set_message(t('Sucessfully deleted File ID : %fid from the file_managed table.', [
      '%fid' => $file_id,
    ]));
  }
}