Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Problem/Motivation
If I
create three entity types of Email (easy_email), Customer and Organisation
the Email entity type has an entity reference field to the Customer entity type
the Customer entity type has a reference field to the Organisation entity type
I should be able to see Organisation filed tokens if the token browser is invoked with:
$form['customize']['tokens']['tokens'] = [
'#theme' => 'token_tree_link',
'#token_types' => ['easy_email'],
'#show_restricted' => TRUE,
'#recursion_limit' => 6,
];
But this does not work.
Proposed resolution
The problem occurs because of:
if (empty($token_parents)) {
// If the parents array is currently empty, assume the token type is its
// parent.
$token_parents[] = $token_type;
}
elseif (in_array($token, array_slice($token_parents, 1), TRUE)) {
// Prevent duplicate recursive tokens. For example, this will prevent
// the tree from generating the following tokens or deeper:
// [comment:parent:parent]
// [comment:parent:root:parent]
continue;
}
in \Drupal\token\TreeBuilder::getTokenData(). When it is processing the association entity $token
will equal entity
but we'll already have a parent called entity
from the customer entity reference field.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#2 | 3160735-2.patch | 713 bytes | alexpott |
Comments
Comment #2
alexpottHere's a fix - let's see what breaks.
Comment #3
BerdirCommitted.
Comment #5
BerdirHuh, that bug still exists.