You are here

function addressfield_get_address_fields in Address Field 7

Returns a list of address fields optionally filtered by entity type.

Parameters

string $entity_type: Optional machine-name of an entity type to filter the returned array by.

Return value

array An array of address field mapping data.

2 calls to addressfield_get_address_fields()
addressfield_tokens in ./addressfield.tokens.inc
Implements hook_tokens().
addressfield_token_info_alter in ./addressfield.tokens.inc
Implements hook_token_info_alter().

File

./addressfield.module, line 64
Defines a field for attaching country-specific addresses to entities.

Code

function addressfield_get_address_fields($entity_type = '') {
  $fields =& drupal_static(__FUNCTION__ . '_' . $entity_type);
  if (isset($fields)) {
    return $fields;
  }

  // Get mapping data for all address fields.
  $fields = array_filter(field_info_field_map(), 'addressfield_field_map_filter');

  // Filter the list of fields by entity type if specified.
  if (!empty($fields) && !empty($entity_type)) {
    foreach ($fields as $field_name => $field) {
      if (!isset($field['bundles'][$entity_type])) {
        unset($fields[$field_name]);
      }
    }
  }
  return $fields;
}