function FileUsageBase::delete
Same name in other branches
- 8.9.x core/modules/file/src/FileUsage/FileUsageBase.php \Drupal\file\FileUsage\FileUsageBase::delete()
- 10 core/modules/file/src/FileUsage/FileUsageBase.php \Drupal\file\FileUsage\FileUsageBase::delete()
- 11.x core/modules/file/src/FileUsage/FileUsageBase.php \Drupal\file\FileUsage\FileUsageBase::delete()
Overrides FileUsageInterface::delete
1 call to FileUsageBase::delete()
- DatabaseFileUsageBackend::delete in core/
modules/ file/ src/ FileUsage/ DatabaseFileUsageBackend.php - Removes a record to indicate that a module is no longer using a file.
2 methods override FileUsageBase::delete()
- DatabaseFileUsageBackend::delete in core/
modules/ file/ src/ FileUsage/ DatabaseFileUsageBackend.php - Removes a record to indicate that a module is no longer using a file.
- TestFileUsage::delete in core/
modules/ system/ tests/ modules/ service_provider_test/ src/ TestFileUsage.php - Removes a record to indicate that a module is no longer using a file.
File
-
core/
modules/ file/ src/ FileUsage/ FileUsageBase.php, line 44
Class
- FileUsageBase
- Defines the base class for database file usage backend.
Namespace
Drupal\file\FileUsageCode
public function delete(FileInterface $file, $module, $type = NULL, $id = NULL, $count = 1) {
// Do not actually mark files as temporary when the behavior is disabled.
if (!$this->configFactory
->get('file.settings')
->get('make_unused_managed_files_temporary')) {
return;
}
// If there are no more remaining usages of this file, mark it as temporary,
// which result in a delete through system_cron().
$usage = \Drupal::service('file.usage')->listUsage($file);
if (empty($usage)) {
$file->setTemporary();
$file->save();
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.