You are here

function entity_metadata_field_text_property_callback in Entity API 7

Additional callback to adapt the property info for text fields. If a text field is processed we make use of a separate data structure so that format filters are available too. For the text value that is sanitized, this processed value is returned by default.

See also

entity_metadata_field_entity_property_info()

entity_field_info_alter()

entity_property_text_formatted_info()

1 string reference to 'entity_metadata_field_text_property_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 92
Provides info for fields.

Code

function entity_metadata_field_text_property_callback(&$info, $entity_type, $field, $instance, $field_type) {
  if (!empty($instance['settings']['text_processing']) || $field['type'] == 'text_with_summary') {

    // Define a data structure for dealing with text that is formatted or has
    // a summary.
    $property =& $info[$entity_type]['bundles'][$instance['bundle']]['properties'][$field['field_name']];
    $property['getter callback'] = 'entity_metadata_field_verbatim_get';
    $property['setter callback'] = 'entity_metadata_field_verbatim_set';
    unset($property['query callback']);
    if (empty($instance['settings']['text_processing'])) {
      $property['property info'] = entity_property_field_item_textsummary_info();
    }
    else {

      // For formatted text we use the type name 'text_formatted'.
      $property['type'] = $field['cardinality'] != 1 ? 'list<text_formatted>' : 'text_formatted';
      $property['property info'] = entity_property_text_formatted_info();
    }

    // Enable auto-creation of the item, so that it is possible to just set
    // the textual or summary value.
    $property['auto creation'] = 'entity_property_create_array';
    if ($field['type'] != 'text_with_summary') {
      unset($property['property info']['summary']);
    }
  }
}