function field_entity_field_info

Implements hook_entity_field_info() to define all configured fields.

Related topics

File

drupal/core/modules/field/field.module, line 392
Attach custom data fields to Drupal entities.

Code

function field_entity_field_info($entity_type) {
  $property_info = array();
  $field_types = field_info_field_types();
  foreach (field_info_instances($entity_type) as $bundle_name => $instances) {
    $optional = $bundle_name != $entity_type;
    foreach ($instances as $field_name => $instance) {
      $field = field_info_field($field_name);
      if (!empty($field_types[$field['type']]['field item class'])) {

        // @todo: Allow for adding field type settings.
        $definition = array(
          'label' => t('Field !name', array(
            '!name' => $field_name,
          )),
          'type' => $field['type'] . '_field',
          'configurable' => TRUE,
          'translatable' => !empty($field['translatable']),
        );
        if ($optional) {
          $property_info['optional'][$field_name] = $definition;
          $property_info['bundle map'][$bundle_name][] = $field_name;
        }
        else {
          $property_info['definitions'][$field_name] = $definition;
        }
      }
    }
  }
  return $property_info;
}