You are here

function ServiceAuditFilesReferencedNotUsed::_auditfiles_referenced_not_used_batch_delete_create_batch in Audit Files 8

Creates the batch for deleting file references from their content.

Parameters

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

Return value

array The definition of the batch.

File

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

Class

ServiceAuditFilesReferencedNotUsed

Namespace

Drupal\auditfiles

Code

function _auditfiles_referenced_not_used_batch_delete_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('Deleting file references from their content');
  $operations = $reference_ids = [];
  foreach ($referenceids as $reference_id) {
    if ($reference_id != '') {
      $reference_ids[] = $reference_id;
    }
  }

  // Fill in the $operations variable.
  foreach ($reference_ids as $reference_id) {
    $operations[] = [
      '\\Drupal\\auditfiles\\AuditFilesBatchProcess::_auditfiles_referenced_not_used_batch_delete_process_batch',
      [
        $reference_id,
      ],
    ];
  }
  $batch['operations'] = $operations;
  return $batch;
}