class AuditFilesNotOnServerBatchProcess in Audit Files 4.x
Same name and namespace in other branches
- 8.3 src/Batch/AuditFilesNotOnServerBatchProcess.php \Drupal\auditfiles\Batch\AuditFilesNotOnServerBatchProcess
Process batch files.
Hierarchy
- class \Drupal\auditfiles\Batch\AuditFilesNotOnServerBatchProcess
Expanded class hierarchy of AuditFilesNotOnServerBatchProcess
File
- src/
Batch/ AuditFilesNotOnServerBatchProcess.php, line 12
Namespace
Drupal\auditfiles\BatchView source
class AuditFilesNotOnServerBatchProcess {
/**
* The File entity ID to process.
*
* @var int
*/
protected $fileId;
/**
* NotOnServer service.
*
* @var \Drupal\auditfiles\ServiceAuditFilesNotOnServer
*/
protected $notOnServer;
/**
* Class constructor.
*
* @param \Drupal\auditfiles\ServiceAuditFilesNotOnServer $not_on_server
* Injected ServiceAuditFilesNotOnServer service.
* @param int $file_id
* File entity ID to delete.
*/
public function __construct(ServiceAuditFilesNotOnServer $not_on_server, $file_id) {
$this->notOnServer = $not_on_server;
$this->fileId = $file_id;
}
/**
* The batch process for deleting the file.
*
* Used by the Batch API to keep track of and pass data from one operation to
* the next.
*
* @param int $file_id
* File entity ID to delete.
* @param array $context
* Batch context.
*/
public static function auditfilesNotOnServerBatchDeleteProcessBatch($file_id, array &$context) {
$notOnServer = \Drupal::service('auditfiles.not_on_server');
$worker = new static($notOnServer, $file_id);
$worker
->dispatch($context);
}
/**
* Processes file removal from file_usage that are not referenced in content.
*
* @param array $context
* Batch context.
*/
protected function dispatch(array &$context) {
$this->notOnServer
->auditfilesNotOnServerBatchDeleteProcessFile($this->fileId);
$context['results'][] = Html::escape($this->fileId);
$context['message'] = new TranslatableMarkup('Processed file ID %file_id.', [
'%file_id' => $this->fileId,
]);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AuditFilesNotOnServerBatchProcess:: |
protected | property | The File entity ID to process. | |
AuditFilesNotOnServerBatchProcess:: |
protected | property | NotOnServer service. | |
AuditFilesNotOnServerBatchProcess:: |
public static | function | The batch process for deleting the file. | |
AuditFilesNotOnServerBatchProcess:: |
protected | function | Processes file removal from file_usage that are not referenced in content. | |
AuditFilesNotOnServerBatchProcess:: |
public | function | Class constructor. |