commit 6f3282b1b6160dd188d9f19cfb14e26c2fe7a4a8 Author: Christina Glock Date: Wed Oct 7 19:21:27 2015 +0200 Updated patch. diff --git a/token.tokens.inc b/token.tokens.inc index ee2048f..2679ce5 100644 --- a/token.tokens.inc +++ b/token.tokens.inc @@ -1377,6 +1377,7 @@ function field_tokens($type, $tokens, array $data = array(), array $options = ar if ($langcode && $chained_entity->hasTranslation($langcode)) { $chained_entity = $chained_entity->getTranslation($langcode); } + $bubbleable_metadata->addCacheableDependency($chained_entity); $chained_field_token_candidates[$field_name] = array( 'chained_token_type' => $chained_token_type, 'data' => array($chained_token_type => $chained_entity), @@ -1385,6 +1386,7 @@ function field_tokens($type, $tokens, array $data = array(), array $options = ar } // For a multiple field the delta is given as chained token. else { + $bubbleable_metadata->addCacheableDependency($field); if (isset($field_property_definition['value']) && ($field_property_definition['value']->getDataType() == 'timestamp' )) { $chained_field_token_candidates[$field_name] = array( 'chained_token_type' => 'multiple_field_date', @@ -1416,7 +1418,7 @@ function field_tokens($type, $tokens, array $data = array(), array $options = ar if ($chained_field_tokens = $token_service->findWithPrefix($tokens, $chained_field_token_name)) { $chained_data = $chained_field_token_info['data']; $chained_token_type = $chained_field_token_info['chained_token_type']; - $replacements += $token_service->generate($chained_token_type, $chained_field_tokens, $chained_data, $options); + $replacements += $token_service->generate($chained_token_type, $chained_field_tokens, $chained_data, $options, $bubbleable_metadata); } } @@ -1439,25 +1441,19 @@ function field_tokens($type, $tokens, array $data = array(), array $options = ar if (!isset($token_name_list[1])) { $field_output = $field[$delta]->view('token'); $field_output['#token_options'] = $options; - $field_output['#pre_render'][] = 'token_pre_render_field_token'; $replacements[$original] = drupal_render($field_output); } // Chained token given. else { - if ($type == 'multiple_field_value') { - $field_output = $field[$delta]->view('token'); - $field_output['#token_options'] = $options; - $field_output['#pre_render'][] = 'token_pre_render_field_token'; - $replacements[$original] = drupal_render($field_output); - } - // Timestamps and entity references can be chained. - elseif ($type == 'multiple_field_date') { + // Timestamps can be chained. + if ($type == 'multiple_field_date') { $chained_field_token_candidates[$delta] = array( 'chained_token_type' => 'date', 'data' => array('date' => $field[$delta]->value), ); } - else { + // Entity references can be chained. + elseif($type != 'multiple_field_value') { $field_storage_definition = $field->getFieldDefinition()->getFieldStorageDefinition(); $field_property_definition = $field_storage_definition->getPropertyDefinitions(); $chained_token_type = $field_property_definition['entity']->getTargetDefinition()->getEntityTypeId(); @@ -1465,6 +1461,7 @@ function field_tokens($type, $tokens, array $data = array(), array $options = ar if ($langcode && $chained_entity->hasTranslation($langcode)) { $chained_entity = $chained_entity->getTranslation($langcode); } + $bubbleable_metadata->addCacheableDependency($chained_entity); $chained_field_token_candidates[$delta] = array( 'chained_token_type' => $chained_token_type, 'data' => array($chained_token_type => $chained_entity), @@ -1481,7 +1478,7 @@ function field_tokens($type, $tokens, array $data = array(), array $options = ar if ($chained_field_tokens = $token_service->findWithPrefix($tokens, $chained_field_token_name)) { $chained_data = $chained_field_token_info['data']; $chained_token_type = $chained_field_token_info['chained_token_type']; - $replacements += $token_service->generate($chained_token_type, $chained_field_tokens, $chained_data, $options); + $replacements += $token_service->generate($chained_token_type, $chained_field_tokens, $chained_data, $options, $bubbleable_metadata); } }