You are here

function ServiceAuditFilesUsedNotReferenced::_auditfiles_used_not_referenced_batch_delete_create_batch in Audit Files 8

Creates the batch for deleting files from the file_usage table.

File

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

Class

ServiceAuditFilesUsedNotReferenced

Namespace

Drupal\auditfiles

Code

function _auditfiles_used_not_referenced_batch_delete_create_batch(array $fileids) {
  $batch['error_message'] = t('One or more errors were encountered processing the files.');
  $batch['finished'] = '\\Drupal\\auditfiles\\AuditFilesBatchProcess::_auditfiles_used_not_referenced_batch_finish_batch';
  $batch['progress_message'] = t('Completed @current of @total operations.');
  $batch['title'] = t('Deleting files from the file_usage table');
  $operations = $file_ids = [];
  foreach ($fileids as $file_id) {
    if ($file_id != 0) {
      $file_ids[] = $file_id;
    }
  }
  foreach ($file_ids as $file_id) {
    $operations[] = [
      '\\Drupal\\auditfiles\\AuditFilesBatchProcess::_auditfiles_used_not_referenced_batch_delete_process_batch',
      [
        $file_id,
      ],
    ];
  }
  $batch['operations'] = $operations;
  return $batch;
}