public function FileUsageBase::delete

Implements Drupal\file\FileUsage\FileUsageInterface::delete().

Overrides FileUsageInterface::delete

1 call to FileUsageBase::delete()
DatabaseFileUsageBackend::delete in drupal/core/modules/file/lib/Drupal/file/FileUsage/DatabaseFileUsageBackend.php
Implements Drupal\file\FileUsage\FileUsageInterface::delete().
1 method overrides FileUsageBase::delete()
DatabaseFileUsageBackend::delete in drupal/core/modules/file/lib/Drupal/file/FileUsage/DatabaseFileUsageBackend.php
Implements Drupal\file\FileUsage\FileUsageInterface::delete().

File

drupal/core/modules/file/lib/Drupal/file/FileUsage/FileUsageBase.php, line 31
Definition of Drupal\file\FileUsage\FileUsageBase.

Class

FileUsageBase
Defines the base class for database file usage backend.

Namespace

Drupal\file\FileUsage

Code

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();
  }
}