function hook_file_delete

Respond to file deletion.

This hook is invoked after the file has been removed from the filesystem and after its records have been removed from the database.

Parameters

Drupal\file\File $file: The file that has just been deleted.

See also

hook_file_predelete()

Drupal\file\FileStorageController::delete()

1 function implements hook_file_delete()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

entity_crud_hook_test_file_delete in drupal/core/modules/system/tests/modules/entity_crud_hook_test/entity_crud_hook_test.module
Implements hook_file_delete().

File

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

Code

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

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