AuditFilesMergeFileReferencesBatchProcess.php in Audit Files 8.3
File
src/Batch/AuditFilesMergeFileReferencesBatchProcess.php
View source
<?php
namespace Drupal\auditfiles\Batch;
use Drupal\Component\Utility\Html;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\auditfiles\ServiceAuditFilesMergeFileReferences;
class AuditFilesMergeFileReferencesBatchProcess {
protected $fileId;
protected $fileIds;
protected $mergeFileReferences;
public function __construct(ServiceAuditFilesMergeFileReferences $merge_file_references, $file_being_kept, array $files_being_merged) {
$this->mergeFileReferences = $merge_file_references;
$this->fileId = $file_being_kept;
$this->fileIds = $files_being_merged;
}
public static function auditfilesMergeFileReferencesBatchMergeProcessBatch($file_being_kept, array $files_being_merged, array &$context) {
$mergeFileReferences = \Drupal::service('auditfiles.merge_file_references');
$worker = new static($mergeFileReferences, $file_being_kept, $files_being_merged);
$worker
->dispatch($context);
}
protected function dispatch(array &$context) {
$this->mergeFileReferences
->auditfilesMergeFileReferencesBatchMergeProcessFile($this->fileId, $this->fileIds);
$context['results'][] = Html::escape($this->fileId);
$context['results'][] = Html::escape($this->filesIds);
$context['message'] = new TranslatableMarkup('Merged file ID %file_being_merged into file ID %file_being_kept.', [
'%file_being_kept' => $this->fileId,
'%file_being_merged' => $this->fileIds,
]);
}
}