Loading tests/src/Kernel/TaxonomyTest.php +4 −0 Original line number Diff line number Diff line Loading @@ -134,6 +134,10 @@ class TaxonomyTest extends KernelTestBase { 'name' => 'german-parent-term', ])->save(); // Check translation source tokens. $this->assertTokens('term', ['term' => $parent_term], ['source:name' => 'english-parent-term']); $this->assertTokens('term', ['term' => $parent_term], ['source:name' => 'english-parent-term'], ['langcode' => 'de']); // Create a term related to the parent term. $child_term = $this->addTerm($this->vocab, [ 'name' => 'english-child-term', Loading token.tokens.inc +10 −0 Original line number Diff line number Diff line Loading @@ -177,6 +177,11 @@ function token_token_info() { // Taxonomy term and vocabulary tokens. if (\Drupal::moduleHandler()->moduleExists('taxonomy')) { $info['tokens']['term']['source'] = [ 'name' => t('Translation source term'), 'description' => t("The source term for this current term's translation set."), 'type' => 'term', ]; $info['tokens']['term']['edit-url'] = [ 'name' => t('Edit URL'), 'description' => t("The URL of the taxonomy term's edit page."), Loading Loading @@ -613,6 +618,11 @@ function token_tokens($type, array $tokens, array $data, array $options, Bubblea } // Chained token relationships. if (($parent_tokens = \Drupal::token()->findWithPrefix($tokens, 'source')) && $source_term = \Drupal::service('entity.repository')->getTranslationFromContext($term, LanguageInterface::LANGCODE_DEFAULT)) { $replacements += \Drupal::token()->generate('term', $parent_tokens, [ 'term' => $source_term, ], ['langcode' => $source_term->language()->getId()] + $options, $bubbleable_metadata); } if (($url_tokens = \Drupal::token()->findWithPrefix($tokens, 'url'))) { $replacements += \Drupal::token()->generate('url', $url_tokens, ['url' => $term->toUrl()], $options, $bubbleable_metadata); } Loading Loading
tests/src/Kernel/TaxonomyTest.php +4 −0 Original line number Diff line number Diff line Loading @@ -134,6 +134,10 @@ class TaxonomyTest extends KernelTestBase { 'name' => 'german-parent-term', ])->save(); // Check translation source tokens. $this->assertTokens('term', ['term' => $parent_term], ['source:name' => 'english-parent-term']); $this->assertTokens('term', ['term' => $parent_term], ['source:name' => 'english-parent-term'], ['langcode' => 'de']); // Create a term related to the parent term. $child_term = $this->addTerm($this->vocab, [ 'name' => 'english-child-term', Loading
token.tokens.inc +10 −0 Original line number Diff line number Diff line Loading @@ -177,6 +177,11 @@ function token_token_info() { // Taxonomy term and vocabulary tokens. if (\Drupal::moduleHandler()->moduleExists('taxonomy')) { $info['tokens']['term']['source'] = [ 'name' => t('Translation source term'), 'description' => t("The source term for this current term's translation set."), 'type' => 'term', ]; $info['tokens']['term']['edit-url'] = [ 'name' => t('Edit URL'), 'description' => t("The URL of the taxonomy term's edit page."), Loading Loading @@ -613,6 +618,11 @@ function token_tokens($type, array $tokens, array $data, array $options, Bubblea } // Chained token relationships. if (($parent_tokens = \Drupal::token()->findWithPrefix($tokens, 'source')) && $source_term = \Drupal::service('entity.repository')->getTranslationFromContext($term, LanguageInterface::LANGCODE_DEFAULT)) { $replacements += \Drupal::token()->generate('term', $parent_tokens, [ 'term' => $source_term, ], ['langcode' => $source_term->language()->getId()] + $options, $bubbleable_metadata); } if (($url_tokens = \Drupal::token()->findWithPrefix($tokens, 'url'))) { $replacements += \Drupal::token()->generate('url', $url_tokens, ['url' => $term->toUrl()], $options, $bubbleable_metadata); } Loading