Issue #2157153 by yched, Berdir: Remove field_attach_preprocess().
parent
284241ecb9
commit
a1a98382bc
|
@ -1456,9 +1456,6 @@ function template_preprocess_comment(&$variables) {
|
|||
$variables['parent'] = '';
|
||||
}
|
||||
|
||||
// Preprocess fields.
|
||||
field_attach_preprocess($comment, $variables['elements'], $variables);
|
||||
|
||||
// Helpful $content variable for templates.
|
||||
foreach (element_children($variables['elements']) as $key) {
|
||||
$variables['content'][$key] = $variables['elements'][$key];
|
||||
|
|
|
@ -357,24 +357,6 @@ function hook_field_attach_extract_form_values(\Drupal\Core\Entity\EntityInterfa
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Alter field_attach_preprocess() variables.
|
||||
*
|
||||
* This hook is invoked while preprocessing field templates in
|
||||
* field_attach_preprocess().
|
||||
*
|
||||
* @param $variables
|
||||
* The variables array is passed by reference and will be populated with field
|
||||
* values.
|
||||
* @param $context
|
||||
* An associative array containing:
|
||||
* - entity: The entity with fields to render.
|
||||
* - element: The structured array containing the values ready for rendering.
|
||||
*/
|
||||
function hook_field_attach_preprocess_alter(&$variables, $context) {
|
||||
// @todo Needs function body.
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform alterations on field_attach_view() or field_view_field().
|
||||
*
|
||||
|
|
|
@ -265,38 +265,6 @@ function _field_invoke_widget_target($form_display) {
|
|||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates the template variables with the available field values.
|
||||
*
|
||||
* The $variables array will be populated with all the field instance values
|
||||
* associated with the given entity type, keyed by field name; in case of
|
||||
* translatable fields the language currently chosen for display will be
|
||||
* selected.
|
||||
*
|
||||
* @param \Drupal\Core\Entity\EntityInterface $entity
|
||||
* The entity with fields to render.
|
||||
* @param $element
|
||||
* The structured array containing the values ready for rendering.
|
||||
* @param $variables
|
||||
* The variables array is passed by reference and will be populated with field
|
||||
* values.
|
||||
*/
|
||||
function field_attach_preprocess(EntityInterface $entity, $element, &$variables) {
|
||||
foreach (field_info_instances($entity->entityType(), $entity->bundle()) as $field_name => $instance) {
|
||||
if (isset($element[$field_name]['#language'])) {
|
||||
$langcode = $element[$field_name]['#language'];
|
||||
$variables[$field_name] = $entity->getTranslation($langcode)->{$field_name}->getValue();
|
||||
}
|
||||
}
|
||||
|
||||
// Let other modules make changes to the $variables array.
|
||||
$context = array(
|
||||
'entity' => $entity,
|
||||
'element' => $element,
|
||||
);
|
||||
drupal_alter('field_attach_preprocess', $variables, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* @} End of "defgroup field_attach".
|
||||
*/
|
||||
|
|
|
@ -160,18 +160,6 @@ class FieldAttachOtherTest extends FieldUnitTestBase {
|
|||
|
||||
// TODO:
|
||||
// - check display order with several fields
|
||||
|
||||
// Preprocess template.
|
||||
$variables = array();
|
||||
field_attach_preprocess($entity, $entity->content, $variables);
|
||||
$result = TRUE;
|
||||
foreach ($values as $delta => $item) {
|
||||
if ($variables[$this->field_name][$delta]['value'] !== $item['value']) {
|
||||
$result = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->assertTrue($result, format_string('Variable $@field_name correctly populated.', array('@field_name' => $this->field_name)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -688,9 +688,6 @@ function template_preprocess_node(&$variables) {
|
|||
$variables['content'][$key] = $variables['elements'][$key];
|
||||
}
|
||||
|
||||
// Make the field variables available with the appropriate language.
|
||||
field_attach_preprocess($node, $variables['content'], $variables);
|
||||
|
||||
// Display post information only on certain node types.
|
||||
// Avoid loading the entire node type config entity here that may not exist.
|
||||
$node_type_config = \Drupal::config('node.type.' . $node->bundle());
|
||||
|
|
|
@ -400,12 +400,6 @@ function template_preprocess_taxonomy_term(&$variables) {
|
|||
$variables['content'][$key] = $variables['elements'][$key];
|
||||
}
|
||||
|
||||
// field_attach_preprocess() overwrites the $[field_name] variables with the
|
||||
// values of the field in the language that was selected for display, instead
|
||||
// of the raw values in $term->[field_name], which contain all values in all
|
||||
// languages.
|
||||
field_attach_preprocess($term, $variables['content'], $variables);
|
||||
|
||||
// Gather classes, and clean up name so there are no underscores.
|
||||
$variables['attributes']['class'][] = 'taxonomy-term';
|
||||
$vocabulary_name_css = str_replace('_', '-', $term->bundle());
|
||||
|
|
|
@ -113,9 +113,6 @@ function template_preprocess_user(&$variables) {
|
|||
$variables['content'][$key] = $variables['elements'][$key];
|
||||
}
|
||||
|
||||
// Preprocess fields.
|
||||
field_attach_preprocess($account, $variables['elements'], $variables);
|
||||
|
||||
// Set up attributes.
|
||||
$variables['attributes']['class'][] = 'profile';
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue