You are here

function ServiceAuditFilesReferencedNotUsed::_auditfiles_referenced_not_used_batch_add_create_batch in Audit Files 8

Creates the batch for adding files to the file_usage table.

Parameters

array $referenceids: The list of IDs to be processed.

Return value

array The definition of the batch.

File

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

Class

ServiceAuditFilesReferencedNotUsed

Namespace

Drupal\auditfiles

Code

function _auditfiles_referenced_not_used_batch_add_create_batch(array $referenceids) {
  $batch['error_message'] = t('One or more errors were encountered processing the files.');
  $batch['finished'] = '\\Drupal\\auditfiles\\AuditFilesBatchProcess::_auditfiles_referenced_not_used_batch_finish_batch';
  $batch['progress_message'] = t('Completed @current of @total operations.');
  $batch['title'] = t('Adding files to the file_usage table');
  $operations = $reference_ids = [];
  foreach ($referenceids as $reference_id) {
    if (!empty($reference_id)) {
      $reference_ids[] = $reference_id;
    }
  }
  foreach ($reference_ids as $reference_id) {
    $operations[] = [
      '\\Drupal\\auditfiles\\AuditFilesBatchProcess::_auditfiles_referenced_not_used_batch_add_process_batch',
      [
        $reference_id,
      ],
    ];
  }
  $batch['operations'] = $operations;
  return $batch;
}