commit cb8419dda3b8824e0f151f0eda0803e20090a027 Author: Joel Pittet Date: Mon Mar 31 18:47:15 2014 -0700 convert field__node__title diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 5eca228..d1d152f 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -2396,17 +2396,24 @@ function template_preprocess_field(&$variables, $hook) { $default_attributes = new Attribute; } - // Modules (e.g., rdf.module) can add field item attributes (to - // $item->_attributes) within hook_entity_prepare_view(). Some field - // formatters move those attributes into some nested formatter-specific - // element in order have them rendered on the desired HTML element (e.g., on - // the element of a field item being rendered as a link). Other field - // formatters leave them within $element['#items'][$delta]['_attributes'] to - // be rendered on the item wrappers provided by field.html.twig. + // We want other preprocess functions and the theme implementation to have + // fast access to the field item render arrays. The item render array keys + // (deltas) should always be numerically indexed starting from 0, and looping + // on those keys is faster than calling element_children() or looping on all + // keys within $element, since that requires traversal of all element + // properties. $variables['items'] = array(); $delta = 0; while (!empty($element[$delta])) { $variables['items'][$delta]['value'] = $element[$delta]; + + // Modules (e.g., rdf.module) can add field item attributes (to + // $item->_attributes) within hook_entity_prepare_view(). Some field + // formatters move those attributes into some nested formatter-specific + // element in order have them rendered on the desired HTML element (e.g., on + // the element of a field item being rendered as a link). Other field + // formatters leave them within $element['#items'][$delta]['_attributes'] to + // be rendered on the item wrappers provided by field.html.twig. $variables['items'][$delta]['attributes'] = !empty($element['#items'][$delta]->_attributes) ? new Attribute($element['#items'][$delta]->_attributes) : clone($default_attributes); $delta++; }