1 file.pages.inc | _file_usage_get_total(File $file) |
Get the complete total number of known usages for a file.
Parameters
File $file: A file entity object.
Return value
int: The complete number of usages.
File
- core/
modules/ file/ file.pages.inc, line 1023 - Supports file operations including Manage and Delete.
Code
function _file_usage_get_total(File $file) {
$total = 0;
if ($file_usage_list = file_usage_list($file)) {
foreach ($file_usage_list as $module_name => $module_usages) {
foreach ($module_usages as $entity_type => $entity_usages) {
foreach ($entity_usages as $entity_id => $usage_count) {
$total += $usage_count;
}
}
}
}
return $total;
}