class AcsfDuplicationScrubTemporaryFilesHandler in Acquia Cloud Site Factory Connector 8
Same name and namespace in other branches
- 8.2 src/Event/AcsfDuplicationScrubTemporaryFilesHandler.php \Drupal\acsf\Event\AcsfDuplicationScrubTemporaryFilesHandler
Handles the scrubbing of Drupal temporary files.
Hierarchy
- class \Drupal\acsf\Event\AcsfEventHandler
- class \Drupal\acsf\Event\AcsfDuplicationScrubTemporaryFilesHandler
Expanded class hierarchy of AcsfDuplicationScrubTemporaryFilesHandler
File
- src/
Event/ AcsfDuplicationScrubTemporaryFilesHandler.php, line 8
Namespace
Drupal\acsf\EventView source
class AcsfDuplicationScrubTemporaryFilesHandler extends AcsfEventHandler {
/**
* Implements AcsfEventHandler::handle().
*/
public function handle() {
drush_print(dt('Entered @class', [
'@class' => get_class($this),
]));
$file_storage = \Drupal::entityTypeManager()
->getStorage('file');
// Remove all temporary files. As in file_cron(), temporary is encoded as
// "<> FILE_STATUS_PERMANENT".
$fids = $file_storage
->getQuery()
->condition('status', FILE_STATUS_PERMANENT, '<>')
->range(0, 1000)
->execute();
$files = $file_storage
->loadMultiple($fids);
foreach ($files as $file) {
$file
->delete();
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AcsfDuplicationScrubTemporaryFilesHandler:: |
public | function |
Implements AcsfEventHandler::handle(). Overrides AcsfEventHandler:: |
|
AcsfEventHandler:: |
public | property | The time that the handler was completed. | |
AcsfEventHandler:: |
public | property | Any messages triggered by the handler. | |
AcsfEventHandler:: |
public | property | The time that the handler was started. | |
AcsfEventHandler:: |
public | function | Constructor. | 1 |