You are here

function merci_core_info_fields in MERCI (Manage Equipment Reservations, Checkout and Inventory) 7.3

Finds all fields 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 fields keyed by the field name.

File

merci_core/merci_core.module, line 361

Code

function merci_core_info_fields($field_type, $entity_type = NULL) {
  $fields = array();

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

      // Add this field to the return array if no entity type was specified or
      // if the specified type exists in the field's bundles array.
      if (empty($entity_type) || in_array($entity_type, array_keys($field_stub['bundles']))) {
        $field = field_info_field($field_name);
        $fields[$field_name] = $field;
      }
    }
  }
  return $fields;
}