Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
token_entity_render
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
token_entity_render
Merge requests
!1
fix(php): fix php warning when checking view_mode validity
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
fix(php): fix php warning when checking view_mode validity
issue/token_entity_render-3425042:2.0.x
into
2.0.x
Overview
0
Commits
2
Pipelines
2
Changes
1
Merged
David Pascoe-Deslauriers
requested to merge
issue/token_entity_render-3425042:2.0.x
into
2.0.x
1 year ago
Overview
0
Commits
2
Pipelines
2
Changes
1
Expand
0
0
Merge request reports
Compare
2.0.x
version 2
bcf0f6c7
11 months ago
version 1
0414d416
1 year ago
2.0.x (base)
and
latest version
latest version
ccc3207d
2 commits,
11 months ago
version 2
bcf0f6c7
2 commits,
11 months ago
version 1
0414d416
1 commit,
1 year ago
1 file
+
9
−
8
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
token_entity_render.module
+
9
−
8
Options
@@ -72,16 +72,17 @@ function token_entity_render_tokens($type, array $tokens, array $data, array $op
// Traverse again all tokens to process.
$renderer
=
\Drupal
::
service
(
'renderer'
);
foreach
(
$to_process
as
$token_replaceable_value
=>
$view_mode_name
)
{
$target_view_mode
=
$data
[
'entity_type'
]
.
'.'
.
$view_mode_name
;
// If the view mode actually exists and if the entity type matches.
if
((
$view_mode
=
$all_view_modes
[
$data
[
'entity_type'
]
.
'.'
.
$view_mode_name
]))
{
// The view mode name does not have the entity name.
$mode_machine_name
=
substr
(
$view_mode
->
id
(),
strlen
(
$view_mode
->
getTargetType
())
+
1
);
$rendered_entity
=
\Drupal
::
entityTypeManager
()
->
getViewBuilder
(
$view_mode
->
getTargetType
())
->
view
(
$data
[
'entity'
],
$mode_machine_name
);
// Add the replacement.
$replacements
[
$token_replaceable_value
]
=
$renderer
->
renderPlain
(
$rendered_entity
);
if
(
!
isset
(
$all_view_modes
[
$target_view_mode
]))
{
continue
;
}
$view_mode
=
$all_view_modes
[
$target_view_mode
];
// The view mode name does not have the entity name.
$mode_machine_name
=
substr
(
$view_mode
->
id
(),
strlen
(
$view_mode
->
getTargetType
())
+
1
);
$rendered_entity
=
\Drupal
::
entityTypeManager
()
->
getViewBuilder
(
$view_mode
->
getTargetType
())
->
view
(
$data
[
'entity'
],
$mode_machine_name
);
// Add the replacement.
$replacements
[
$token_replaceable_value
]
=
$renderer
->
renderPlain
(
$rendered_entity
);
}
// Return replacements, if any.
Loading