You are here

function entity_embed_entity_field_count_files in Entity Embed 7.2

Same name and namespace in other branches
  1. 7 includes/entity_embed.file_usage.inc \entity_embed_entity_field_count_files()

Retrieve a count of all of the files referenced by an entity.

Parameters

$entity: The entity whose files are being counted.

$entity_type: The type of the entity whose files are being counted.

Return value

An array of file counts keyed by file ID.

2 calls to entity_embed_entity_field_count_files()
entity_embed_field_attach_delete_revision in includes/entity_embed.file_usage.inc
Implements hook_field_attach_delete_revision().
_entity_embed_filter_add_file_usage_from_fields in includes/entity_embed.file_usage.inc
Add file usage from file references in an entity's text fields.

File

includes/entity_embed.file_usage.inc, line 124
Tracks usage of embedded files.

Code

function entity_embed_entity_field_count_files($entity_type, $entity) {
  $file_count = array();

  // Loop through the entity's file references and create a total count for each
  // file.
  foreach (entity_embed_filter_parse_from_fields($entity_type, $entity) as $fid) {
    if (empty($file_count[$fid])) {
      $file_count[$fid] = 1;
    }
    else {
      $file_count[$fid]++;
    }
  }
  return $file_count;
}