Defines the base class for database file usage backend.
Expanded class hierarchy of FileUsageBase
abstract class FileUsageBase implements FileUsageInterface {
/**
* Implements Drupal\file\FileUsage\FileUsageInterface::add().
*/
public function add(File $file, $module, $type, $id, $count = 1) {
// Make sure that a used file is permament.
if ($file->status != FILE_STATUS_PERMANENT) {
$file->status = FILE_STATUS_PERMANENT;
$file
->save();
}
}
/**
* Implements Drupal\file\FileUsage\FileUsageInterface::delete().
*/
public function delete(File $file, $module, $type = NULL, $id = NULL, $count = 1) {
// If there are no more remaining usages of this file, mark it as temporary,
// which result in a delete through system_cron().
$usage = file_usage()
->listUsage($file);
if (empty($usage)) {
$file->status = 0;
$file
->save();
}
}
}
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FileUsageBase:: |
public | function |
Implements Drupal\file\FileUsage\FileUsageInterface::add(). Overrides FileUsageInterface:: |
1 |
FileUsageBase:: |
public | function |
Implements Drupal\file\FileUsage\FileUsageInterface::delete(). Overrides FileUsageInterface:: |
1 |
FileUsageInterface:: |
public | function | Determines where a file is used. | 1 |