class AuditFilesNotInDatabaseBatchProcess in Audit Files 4.x
Same name and namespace in other branches
- 8.3 src/Batch/AuditFilesNotInDatabaseBatchProcess.php \Drupal\auditfiles\Batch\AuditFilesNotInDatabaseBatchProcess
Process batch files.
Hierarchy
- class \Drupal\auditfiles\Batch\AuditFilesNotInDatabaseBatchProcess
Expanded class hierarchy of AuditFilesNotInDatabaseBatchProcess
File
- src/
Batch/ AuditFilesNotInDatabaseBatchProcess.php, line 12
Namespace
Drupal\auditfiles\BatchView source
class AuditFilesNotInDatabaseBatchProcess {
/**
* The file name to process.
*
* @var string
*/
protected $fileName;
/**
* ReferencedNotUsed service.
*
* @var \Drupal\auditfiles\ServiceAuditFilesNotInDatabase
*/
protected $notInDatabase;
/**
* Class constructor.
*
* @param \Drupal\auditfiles\ServiceAuditFilesNotInDatabase $not_in_database
* Injected ServiceAuditFilesUsedNotManaged service.
* @param string $file_name
* File name to process.
*/
public function __construct(ServiceAuditFilesNotInDatabase $not_in_database, $file_name) {
$this->notInDatabase = $not_in_database;
$this->fileName = $file_name;
}
/**
* The batch process for adding the file.
*
* @param string $filename
* File name that to be process.
* @param array $context
* Batch context.
*/
public static function auditfilesNotInDatabaseBatchAddProcessBatch($filename, array &$context) {
$notInDatabase = \Drupal::service('auditfiles.not_in_database');
$worker = new static($notInDatabase, $filename);
$worker
->addDispatch($context);
}
/**
* Adds filenames referenced in content in file_managed but not in file_usage.
*
* @param array $context
* Batch context.
*/
protected function addDispatch(array &$context) {
$this->notInDatabase
->auditfilesNotInDatabaseBatchAddProcessFile($this->fileName);
$context['results'][] = Html::escape($this->fileName);
$context['message'] = new TranslatableMarkup('Processed %filename.', [
'%filename' => $this->fileName,
]);
}
/**
* The batch process for deleting the file.
*
* @param string $filename
* File name that needs to be processed.
* @param array $context
* Batch context.
*/
public static function auditfilesNotInDatabaseBatchDeleteProcessBatch($filename, array &$context) {
$notInDatabase = \Drupal::service('auditfiles.not_in_database');
$worker = new static($notInDatabase, $filename);
$worker
->deleteDispatch($context);
}
/**
* Deletes filenames referenced in content frm file_managed not in file_usage.
*
* @param array $context
* Batch context.
*/
protected function deleteDispatch(array &$context) {
$this->notInDatabase
->auditfilesNotInDatabaseBatchDeleteProcessFile($this->fileName);
$context['results'][] = Html::escape($this->fileName);
$context['message'] = new TranslatableMarkup('Processed %filename.', [
'%filename' => $this->fileName,
]);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AuditFilesNotInDatabaseBatchProcess:: |
protected | property | The file name to process. | |
AuditFilesNotInDatabaseBatchProcess:: |
protected | property | ReferencedNotUsed service. | |
AuditFilesNotInDatabaseBatchProcess:: |
protected | function | Adds filenames referenced in content in file_managed but not in file_usage. | |
AuditFilesNotInDatabaseBatchProcess:: |
public static | function | The batch process for adding the file. | |
AuditFilesNotInDatabaseBatchProcess:: |
public static | function | The batch process for deleting the file. | |
AuditFilesNotInDatabaseBatchProcess:: |
protected | function | Deletes filenames referenced in content frm file_managed not in file_usage. | |
AuditFilesNotInDatabaseBatchProcess:: |
public | function | Class constructor. |