class AuditFilesManagedNotUsedBatchProcess in Audit Files 4.x
Same name and namespace in other branches
- 8.3 src/Batch/AuditFilesManagedNotUsedBatchProcess.php \Drupal\auditfiles\Batch\AuditFilesManagedNotUsedBatchProcess
Batch Worker to handle Deleting entity records from file_managed table.
Hierarchy
- class \Drupal\auditfiles\Batch\AuditFilesManagedNotUsedBatchProcess
Expanded class hierarchy of AuditFilesManagedNotUsedBatchProcess
File
- src/
Batch/ AuditFilesManagedNotUsedBatchProcess.php, line 12
Namespace
Drupal\auditfiles\BatchView source
class AuditFilesManagedNotUsedBatchProcess {
/**
* The File entity ID to delete.
*
* @var int
*/
protected $fileId;
/**
* ManagedNotUsed service.
*
* @var \Drupal\auditfiles\ServiceAuditFilesManagedNotUsed
*/
protected $managedNotUsed;
/**
* Class constructor.
*
* @param \Drupal\auditfiles\ServiceAuditFilesManagedNotUsed $managed_not_used
* Injected ServiceAuditFilesManagedNotUsed service.
* @param int $file_id
* File entity ID to delete.
*/
public function __construct(ServiceAuditFilesManagedNotUsed $managed_not_used, $file_id) {
$this->managedNotUsed = $managed_not_used;
$this->fileId = $file_id;
}
/**
* Batch process to delete file entities from file_managed not in file_usage.
*
* @param int $file_id
* File entity ID to delete.
* @param array $context
* Batch context.
*/
public static function auditfilesManagedNotUsedBatchDeleteProcessBatch($file_id, array &$context) {
$managedNotUsed = \Drupal::service('auditfiles.managed_not_used');
$worker = new static($managedNotUsed, $file_id);
$worker
->dispatch($context);
}
/**
* Processes removal of files from file_managed that are not in file_usage.
*
* @param array $context
* Batch context.
*/
protected function dispatch(array &$context) {
$this->managedNotUsed
->auditfilesManagedNotUsedBatchDeleteProcessFile($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 |
---|---|---|---|---|
AuditFilesManagedNotUsedBatchProcess:: |
protected | property | The File entity ID to delete. | |
AuditFilesManagedNotUsedBatchProcess:: |
protected | property | ManagedNotUsed service. | |
AuditFilesManagedNotUsedBatchProcess:: |
public static | function | Batch process to delete file entities from file_managed not in file_usage. | |
AuditFilesManagedNotUsedBatchProcess:: |
protected | function | Processes removal of files from file_managed that are not in file_usage. | |
AuditFilesManagedNotUsedBatchProcess:: |
public | function | Class constructor. |