Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By Berdir on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
7.x-1.x
Introduced in version:
7.x-1.0-alpha3
Issue links:
Description:
To simplify implementations and preventing language selection bugs, the arguments to the mentioned hook have been changed().
Before:
function hook_tmgmt_source_translation_structure($field_name, $entity_type, $entity, $field_instance) {
}
New:
function hook_tmgmt_source_translation_structure($entity_type, $entity, $field, $instance, $langcode, $items) {
}
This means that most implementations can just use $items<code> to extract the values instead of having to load them from the <code>$entity
as visible in the following diff from the text implementation:
-function text_tmgmt_source_translation_structure($field_name, $entity_type, $entity, $field_instance) {
- $field_lang = field_language($entity_type, $entity, $field_name);
+function text_tmgmt_source_translation_structure($entity_type, $entity, $field, $instance, $langcode, $items) {
$structure = array();
- if (!empty($entity->{$field_name}[$field_lang])) {
- $field_info = field_info_field($field_name);
- $structure['#label'] = check_plain($field_instance['label']);
- foreach ($entity->{$field_name}[$field_lang] as $delta => $value) {
+ if (!empty($items)) {
+ $structure['#label'] = check_plain($instance['label']);
+ foreach ($items as $delta => $value) {
Impacts:
Module developers