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
Compare revisions
project-update-bot-only to 2.0.x
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
project/token_entity_render
Select target project
No results found
2.0.x
Select Git revision
Branches
2.0.x
7.x-1.x
8.x-1.x
Tags
2.0.0
2.0.0-alpha1
5 results
Swap
Target
issue/token_entity_render-3435049
Select target project
project/token_entity_render
issue/token_entity_render-3425042
issue/token_entity_render-3435049
issue/token_entity_render-3515134
4 results
project-update-bot-only
Select Git revision
Branches
2.0.x
7.x-1.x
8.x-1.x
project-update-bot-only
Tags
2.0.0-alpha1
5 results
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (3)
Issue
#3435049
: Automated Drupal 11 compatibility fixes for token_entity_render
· 5b393f7d
project update bot
authored
1 year ago
and
Martin Anderson-Clutz
committed
1 year ago
5b393f7d
Issue
#3425595
by mandclu: You have requested a non-existent service "entity.manager"
· cfe86f39
Martin Anderson-Clutz
authored
1 year ago
cfe86f39
Issue
#3425042
by spotzero, mandclu: Formatting of validity check throws a warning on line 76
· 4f97ec21
David Pascoe-Deslauriers
authored
1 year ago
and
Martin Anderson-Clutz
committed
1 year ago
4f97ec21
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
token_entity_render.info.yml
+1
-1
1 addition, 1 deletion
token_entity_render.info.yml
token_entity_render.module
+11
-10
11 additions, 10 deletions
token_entity_render.module
with
12 additions
and
11 deletions
token_entity_render.info.yml
View file @
4f97ec21
name
:
Token Entity Render
description
:
Provides tokens that render full entities using view mode specified
type
:
module
core_version_requirement
:
^9 || ^10
core_version_requirement
:
^9 || ^10
|| ^11
package
:
Token
This diff is collapsed.
Click to expand it.
token_entity_render.module
View file @
4f97ec21
...
...
@@ -12,7 +12,7 @@ use Drupal\Core\Render\BubbleableMetadata;
*/
function
token_entity_render_token_info_alter
(
array
&
$data
)
{
// Load all possible view modes.
$all_view_modes
=
\Drupal
::
service
(
'entity.manager'
)
->
getStorage
(
'entity_view_mode'
)
->
loadMultiple
();
$all_view_modes
=
\Drupal
::
service
(
'entity
_type
.manager'
)
->
getStorage
(
'entity_view_mode'
)
->
loadMultiple
();
// Traverse all view modes.
foreach
(
$all_view_modes
as
$mode
)
{
...
...
@@ -67,21 +67,22 @@ function token_entity_render_tokens($type, array $tokens, array $data, array $op
}
// Load all possible view modes.
$all_view_modes
=
\Drupal
::
service
(
'entity.manager'
)
->
getStorage
(
'entity_view_mode'
)
->
loadMultiple
();
$all_view_modes
=
\Drupal
::
service
(
'entity
_type
.manager'
)
->
getStorage
(
'entity_view_mode'
)
->
loadMultiple
();
// 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.
...
...
This diff is collapsed.
Click to expand it.