You are here

function ServiceAuditFilesNotOnServer::_auditfiles_not_on_server_batch_delete_create_batch in Audit Files 8

Creates the batch for deleting files from the database.

Parameters

array $fileids: The list of file IDs to be processed.

Return value

array The definition of the batch.

File

src/ServiceAuditFilesNotOnServer.php, line 113
providing the service that used in not in database functionality.

Class

ServiceAuditFilesNotOnServer

Namespace

Drupal\auditfiles

Code

function _auditfiles_not_on_server_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_not_on_server_batch_finish_batch';
  $batch['progress_message'] = t('Completed @current of @total operations.');
  $batch['title'] = t('Deleting files from the database');
  $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_not_on_server_batch_delete_process_batch',
      [
        $file_id,
      ],
    ];
  }
  $batch['operations'] = $operations;
  return $batch;
}