You are here

function _commerce_file_field_info_bundles in Commerce File 7

Finds all bundles of a particular field type

Parameters

$field_type: The type of field to search for.

$entity_type: Optional entity type to restrict the search to.

Return value

An array of the matching bundles. If entity_type is not provided, results are keyed by the entity_type.

1 call to _commerce_file_field_info_bundles()
commerce_file_handler_filter_file_product_type::query in views/handlers/commerce_file_handler_filter_file_product_type.inc
Query against the line item's type column using an IN() condition.

File

./commerce_file.module, line 1471
Provides integration of file licenses with Commerce

Code

function _commerce_file_field_info_bundles($field_type, $entity_type) {
  $bundles = array();

  // Loop through the fields looking for any fields of the specified type.
  foreach (field_info_fields() as $field_name => $field) {
    if ($field['type'] == $field_type) {

      // Add if the specified type exists in the field's bundles array.
      if (!empty($field['bundles'][$entity_type])) {
        $bundles += array_combine($field['bundles'][$entity_type], $field['bundles'][$entity_type]);
      }
    }
  }
  return $bundles;
}