1.20.x field.api.php | hook_field_prepare_translation($entity_type, $entity, $field, $instance, $langcode, &$items, $source_entity, $source_langcode) |
Define custom prepare_translation behavior for this module's field types.
Parameters
$entity_type: The type of $entity.
$entity: The entity for the operation.
$field: The field structure for the operation.
$instance: The instance structure for $field on $entity's bundle.
$langcode: The language associated to $items.
$items: $entity->{$field['field_name']}[$langcode], or an empty array if unset.
$source_entity: The source entity from which field values are being copied.
$source_langcode: The source language from which field values are being copied.
Related topics
File
- modules/
field/ field.api.php, line 654 - Hooks provided by the Field module.
Code
function hook_field_prepare_translation($entity_type, $entity, $field, $instance, $langcode, &$items, $source_entity, $source_langcode) {
// If the translating user is not permitted to use the assigned text format,
// we must not expose the source values.
$field_name = $field['field_name'];
$formats = filter_formats();
$format_id = $source_entity->{$field_name}[$source_langcode][0]['format'];
if (!filter_access($formats[$format_id])) {
$items = array();
}
}