You are here

public function ServiceAuditFilesUsedNotReferenced::auditfilesUsedNotReferencedBatchDeleteCreateBatch in Audit Files 8.2

Same name and namespace in other branches
  1. 8.3 src/ServiceAuditFilesUsedNotReferenced.php \Drupal\auditfiles\ServiceAuditFilesUsedNotReferenced::auditfilesUsedNotReferencedBatchDeleteCreateBatch()
  2. 4.x src/ServiceAuditFilesUsedNotReferenced.php \Drupal\auditfiles\ServiceAuditFilesUsedNotReferenced::auditfilesUsedNotReferencedBatchDeleteCreateBatch()

Creates the batch for deleting files from the file_usage table.

File

src/ServiceAuditFilesUsedNotReferenced.php, line 187

Class

ServiceAuditFilesUsedNotReferenced
List all methods used in files used not managed functionality.

Namespace

Drupal\auditfiles

Code

public function auditfilesUsedNotReferencedBatchDeleteCreateBatch(array $fileids) {
  $batch['error_message'] = $this->stringTranslation
    ->translate('One or more errors were encountered processing the files.');
  $batch['finished'] = '\\Drupal\\auditfiles\\AuditFilesBatchProcess::auditfilesUsedNotReferencedBatchFinishBatch';
  $batch['progress_message'] = $this->stringTranslation
    ->translate('Completed @current of @total operations.');
  $batch['title'] = $this->stringTranslation
    ->translate('Deleting files from the file_usage table');
  $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::auditfilesUsedNotReferencedBatchDeleteProcessBatch',
      [
        $file_id,
      ],
    ];
  }
  $batch['operations'] = $operations;
  return $batch;
}