From a1a98382bc76f23c89ba2925d7377da3d7aad41c Mon Sep 17 00:00:00 2001 From: webchick Date: Sat, 4 Jan 2014 11:00:14 -0800 Subject: [PATCH] Issue #2157153 by yched, Berdir: Remove field_attach_preprocess(). --- core/modules/comment/comment.module | 3 -- core/modules/field/field.api.php | 18 ----------- core/modules/field/field.attach.inc | 32 ------------------- .../field/Tests/FieldAttachOtherTest.php | 12 ------- core/modules/node/node.module | 3 -- core/modules/taxonomy/taxonomy.module | 6 ---- core/modules/user/user.pages.inc | 3 -- 7 files changed, 77 deletions(-) diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 0885e90ddcf7..df12f825f436 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -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]; diff --git a/core/modules/field/field.api.php b/core/modules/field/field.api.php index 6d34707718ac..3f59be4cf832 100644 --- a/core/modules/field/field.api.php +++ b/core/modules/field/field.api.php @@ -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(). * diff --git a/core/modules/field/field.attach.inc b/core/modules/field/field.attach.inc index 75ee6a281dfb..f80051935202 100644 --- a/core/modules/field/field.attach.inc +++ b/core/modules/field/field.attach.inc @@ -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". */ diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php index 8f773733acfb..ccd6cd1ae729 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php @@ -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))); } /** diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 9a9f154913d0..8becc7f2ad89 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -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()); diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index 978ac62c6037..e41b46770f48 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -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()); diff --git a/core/modules/user/user.pages.inc b/core/modules/user/user.pages.inc index 297725350785..f9b5a91dd0ac 100644 --- a/core/modules/user/user.pages.inc +++ b/core/modules/user/user.pages.inc @@ -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'; }