Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
a1a98382
Commit
a1a98382
authored
Jan 04, 2014
by
webchick
Browse files
Issue
#2157153
by yched, Berdir: Remove field_attach_preprocess().
parent
284241ec
Changes
7
Hide whitespace changes
Inline
Side-by-side
core/modules/comment/comment.module
View file @
a1a98382
...
...
@@ -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
];
...
...
core/modules/field/field.api.php
View file @
a1a98382
...
...
@@ -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().
*
...
...
core/modules/field/field.attach.inc
View file @
a1a98382
...
...
@@ -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".
*/
core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php
View file @
a1a98382
...
...
@@ -160,18 +160,6 @@ function testFieldAttachView() {
// 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
)));
}
/**
...
...
core/modules/node/node.module
View file @
a1a98382
...
...
@@ -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
());
...
...
core/modules/taxonomy/taxonomy.module
View file @
a1a98382
...
...
@@ -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
());
...
...
core/modules/user/user.pages.inc
View file @
a1a98382
...
...
@@ -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'
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment