You are here

public function ServiceAuditFilesNotInDatabase::auditfilesNotInDatabaseBatchDeleteCreateBatch in Audit Files 8.3

Same name and namespace in other branches
  1. 8.2 src/ServiceAuditFilesNotInDatabase.php \Drupal\auditfiles\ServiceAuditFilesNotInDatabase::auditfilesNotInDatabaseBatchDeleteCreateBatch()
  2. 4.x src/ServiceAuditFilesNotInDatabase.php \Drupal\auditfiles\ServiceAuditFilesNotInDatabase::auditfilesNotInDatabaseBatchDeleteCreateBatch()

Creates the batch for deleting files from the server.

Parameters

array $file_names: The list of file names to be processed.

Return value

array The definition of the batch.

File

src/ServiceAuditFilesNotInDatabase.php, line 499

Class

ServiceAuditFilesNotInDatabase
Define all methods that are used on Files not in database functionality.

Namespace

Drupal\auditfiles

Code

public function auditfilesNotInDatabaseBatchDeleteCreateBatch(array $file_names) {
  $batch['title'] = $this->stringTranslation
    ->translate('Adding files to Drupal file management');
  $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 server');
  $operations = [];
  foreach ($file_names as $file_name) {
    if (!empty($file_name)) {
      $operations[] = [
        '\\Drupal\\auditfiles\\Batch\\AuditFilesNotInDatabaseBatchProcess::auditfilesNotInDatabaseBatchDeleteProcessBatch',
        [
          $file_name,
        ],
      ];
    }
  }
  $batch['operations'] = $operations;
  return $batch;
}