You are here

function entity_embed_field_info_field in Entity Embed 7.3

Our own field-less version of field_info_field().

Parameters

string $entity_type: The entity type of the entity we are trying to embed.

string $module: The module that implements the field formatter we are going to use.

In our version of field_info_field() we don't care at all about the field itself. All we want is the field info array in a format that lets us hack into hook_field_formatter_view() and hook_field_formatter_settings_form(). The problem is that each module may expect something different in this array.

Ideally this would be a simple hook letting other modules do the work, but we will hard-code support for the major players here.

2 calls to entity_embed_field_info_field()
entity_embed_field_info_formatter_settings in includes/entity_embed.display.inc
Our own field-less entity-less version of field_info_formatter_settings().
render_entity_embed_display_plugin in includes/entity_embed.display.inc
Renders an entity using an Entity Embed Display plugin.

File

includes/entity_embed.display.inc, line 429
Display functions.

Code

function entity_embed_field_info_field($entity_type, $module) {
  $field = array();
  $field['field_name'] = '_entity_embed';

  // Support the entityreference module.
  if ('entityreference' == $module) {
    $field['settings'] = field_info_field_settings('entityreference');
    $field['settings']['target_type'] = $entity_type;
  }
  elseif ('user_reference' == $module) {
    $field['settings'] = field_info_field_settings('user_reference');
  }
  elseif ('node_reference' == $module) {
    $field['settings'] = field_info_field_settings('node_reference');
  }
  elseif ('taxonomy' == $module) {
    $field['settings'] = field_info_field_settings('taxonomy_term_reference');
  }
  elseif ('file' == $module || 'file_entity' == $module) {
    $field['settings'] = field_info_field_settings('file');
  }
  elseif ('image' == $module) {
    $field['settings'] = field_info_field_settings('image');
  }
  else {
    $field = module_invoke_all('entity_embed_field_info_field', $entity_type, $module);
  }
  return $field;
}