You are here

function ServiceAuditFilesNotInDatabase::_auditfiles_not_in_database_batch_delete_create_batch in Audit Files 8

Creates the batch for deleting files from the server.

Parameters

array $file_names: The list of file names to be processed.

Return value

array The definition of the batch.

File

src/ServiceAuditFilesNotInDatabase.php, line 397
providing the service that used in not in database functionality.

Class

ServiceAuditFilesNotInDatabase

Namespace

Drupal\auditfiles

Code

function _auditfiles_not_in_database_batch_delete_create_batch(array $file_names) {
  $batch['title'] = t('Adding files to Drupal file management');
  $batch['error_message'] = t('One or more errors were encountered processing the files.');
  $batch['finished'] = '\\Drupal\\auditfiles\\AuditFilesBatchProcess::auditfiles_not_in_database_batch_finish_batch';
  $batch['progress_message'] = t('Completed @current of @total operations.');
  $batch['title'] = t('Deleting files from the server');
  $operations = [];
  $filenames = [];
  foreach ($file_names as $file_name) {
    if (!empty($file_name)) {
      $filenames[] = $file_name;
    }
  }
  foreach ($filenames as $filename) {
    $operations[] = [
      '\\Drupal\\auditfiles\\AuditFilesBatchProcess::auditfiles_not_in_database_batch_delete_process_batch',
      [
        $filename,
      ],
    ];
  }
  $batch['operations'] = $operations;
  return $batch;
}