function entity_embed_field_info_formatter_settings in Entity Embed 7.3
Our own field-less entity-less version of field_info_formatter_settings().
Parameters
$entity_type: The type of entity, i.e. 'node', 'user'.
$entity: The entity to be rendered.
$formatter_type: A formatter type name.
int $settings: Optional array of settings to pass in. If omitted, the formatter's default settings will be returned.
$form: A form array().
$form_state: A form state array.
In our version of field_info_formatter_settings() 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 hook_field_formatter_settings_form().
4 calls to entity_embed_field_info_formatter_settings()
- EntityReferenceFieldFormatterTest::testImageFieldFormatter in ./
entity_embed.test - Tests image field formatter Entity Embed Display plugin.
- entity_embed_dialog_form in ./
entity_embed.admin.inc - Form constructor for the entity embed dialog form.
- FileFieldFormatterTest::testFileFieldFormatter in ./
entity_embed.test - Tests file field formatter Entity Embed Display plugin.
- ImageFieldFormatterTest::testImageFieldFormatter in ./
entity_embed.test - Tests image field formatter Entity Embed Display plugin.
File
- includes/
entity_embed.display.inc, line 519 - Display functions.
Code
function entity_embed_field_info_formatter_settings($entity_type, $entity, $formatter_type, $settings = array(), $form, $form_state) {
$formatter_settings = array();
$field_formatter_info = field_info_formatter_types($formatter_type);
// Invoke hook_field_formatter_settings_form(). We are reusing field
// formatter functions, but we are not working with a Field API field,
// so set $field accordingly. Unfortunately, the API is for $settings to
// be transferred via the $instance parameter, so we must mock it.
if (isset($field_formatter_info['module']) && ($function = $field_formatter_info['module'] . '_field_formatter_settings_form') && function_exists($function)) {
list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
$field = entity_embed_field_info_field($entity_type, $field_formatter_info['module']);
$view_mode = 'default';
$mock_instance = array(
'display' => array(
$view_mode => array(
'type' => $formatter_type,
'settings' => $settings + field_info_formatter_settings($formatter_type),
),
),
'entity_type' => $entity_type,
'bundle' => $bundle,
);
$formatter_settings += $function($field, $mock_instance, $view_mode, $form, $form_state);
}
return $formatter_settings;
}