function hook_file_predelete

Act prior to file deletion.

This hook is invoked when deleting a file before the file is removed from the filesystem and before its records are removed from the database.

Parameters

Drupal\file\File $file: The file that is about to be deleted.

See also

hook_file_delete()

Drupal\file\FileStorageController::delete()

upload_file_delete()

4 functions implement hook_file_predelete()

File

drupal/core/modules/file/file.api.php, line 181
Hooks for file module.

Code

function hook_file_predelete(Drupal\file\File $file) {

  // Delete all information associated with the file.
  db_delete('upload')
    ->condition('fid', $file->fid)
    ->execute();
}