You are here

function ServiceAuditFilesNotInDatabase::_auditfiles_not_in_database_batch_add_create_batch in Audit Files 8

Creates the batch for adding files to the database.

Parameters

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

Return value

array The definition of the batch.

File

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

Class

ServiceAuditFilesNotInDatabase

Namespace

Drupal\auditfiles

Code

function _auditfiles_not_in_database_batch_add_create_batch(array $fileids) {
  $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.');
  $operations = [];
  $file_ids = [];
  foreach ($fileids as $file_id) {
    if (!empty($file_id)) {
      $file_ids[] = $file_id;
    }
  }
  foreach ($file_ids as $file_id) {
    $operations[] = [
      "\\Drupal\\auditfiles\\AuditFilesBatchProcess::auditfiles_not_in_database_batch_add_process_batch",
      [
        $file_id,
      ],
    ];
  }
  $batch['operations'] = $operations;
  return $batch;
}