You are here

function entity_metadata_field_file_callback in Entity API 7

Additional callback to adapt the property info for file fields.

See also

entity_metadata_field_entity_property_info()

1 string reference to 'entity_metadata_field_file_callback'
entity_field_info_alter in includes/entity.property.inc
Implements hook_field_info_alter(). Defines default property types for core field types.

File

modules/field.info.inc, line 143
Provides info for fields.

Code

function entity_metadata_field_file_callback(&$info, $entity_type, $field, $instance, $field_type) {
  $property =& $info[$entity_type]['bundles'][$instance['bundle']]['properties'][$field['field_name']];

  // Define a data structure so it's possible to deal with files and their
  // descriptions.
  $property['getter callback'] = 'entity_metadata_field_verbatim_get';
  $property['setter callback'] = 'entity_metadata_field_verbatim_set';

  // Auto-create the field $items as soon as a property is set.
  $property['auto creation'] = 'entity_metadata_field_file_create_item';
  $property['validation callback'] = 'entity_metadata_field_file_validate_item';
  $property['property info'] = entity_property_field_item_file_info();
  if (empty($instance['settings']['description_field'])) {
    unset($property['property info']['description']);
  }
  if (empty($field['settings']['display_field'])) {
    unset($property['property info']['display']);
  }
  unset($property['query callback']);
}