You are here

public function ServiceAuditFilesUsedNotManaged::auditfilesUsedNotManagedBatchDeleteCreateBatch in Audit Files 4.x

Same name and namespace in other branches
  1. 8.3 src/ServiceAuditFilesUsedNotManaged.php \Drupal\auditfiles\ServiceAuditFilesUsedNotManaged::auditfilesUsedNotManagedBatchDeleteCreateBatch()
  2. 8.2 src/ServiceAuditFilesUsedNotManaged.php \Drupal\auditfiles\ServiceAuditFilesUsedNotManaged::auditfilesUsedNotManagedBatchDeleteCreateBatch()

Creates the batch for deleting files from the file_usage table.

File

src/ServiceAuditFilesUsedNotManaged.php, line 118

Class

ServiceAuditFilesUsedNotManaged
Form for Files used not managed functionality.

Namespace

Drupal\auditfiles

Code

public function auditfilesUsedNotManagedBatchDeleteCreateBatch(array $fileids) {
  $batch['error_message'] = $this->stringTranslation
    ->translate('One or more errors were encountered processing the files.');
  $batch['finished'] = '\\Drupal\\auditfiles\\Batch\\AuditFilesBatchProcess::finishBatch';
  $batch['progress_message'] = $this->stringTranslation
    ->translate('Completed @current of @total operations.');
  $batch['title'] = $this->stringTranslation
    ->translate('Deleting files from the file_usage table');
  $operations = [];
  foreach ($fileids as $file_id) {
    if ($file_id != 0) {
      $operations[] = [
        '\\Drupal\\auditfiles\\Batch\\AuditFilesUsedNotManagedBatchProcess::auditfilesUsedNotManagedBatchDeleteProcessBatch',
        [
          $file_id,
        ],
      ];
    }
  }
  $batch['operations'] = $operations;
  return $batch;
}