You are here

function _commerce_file_field_info_instances in Commerce File 7

Return all commerce_file field type instances

2 calls to _commerce_file_field_info_instances()
commerce_file_refresh_line_item in ./commerce_file.module
Refresh a line item with the current product license data
_commerce_file_field_aggregate_files in includes/commerce_file.field.inc
Return all commerce_file fields for a given entity, indexed by fid

File

includes/commerce_file.field.inc, line 823
Implement an commerce_file field, based on the file module's file field.

Code

function _commerce_file_field_info_instances($entity_type, $entity_bundle, $field_type = COMMERCE_FILE_FIELD_TYPE) {
  $cache =& drupal_static(__FUNCTION__);
  $field_type = !empty($field_type) ? $field_type : COMMERCE_FILE_FIELD_TYPE;
  $cid = "{$entity_type}::{$entity_bundle}::{$field_type}";
  if (!isset($cache[$cid])) {
    $cache[$cid] = array();

    // find all fields instances
    $instances = field_info_instances($entity_type, $entity_bundle);
    if (!empty($instances)) {

      // find all instances for field type
      foreach ($instances as $field_name => $instance) {
        $field_info = field_info_field($field_name);
        if ($field_info['type'] == $field_type) {
          $cache[$cid][$field_name] = $instance;
        }
      }
    }
  }
  return $cache[$cid];
}