Loading core/modules/comment/comment.tokens.inc +8 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,10 @@ function comment_token_info() { 'name' => t("Comment ID"), 'description' => t("The unique ID of the comment."), ]; $comment['uuid'] = [ 'name' => t('UUID'), 'description' => t("The UUID of the comment."), ]; $comment['hostname'] = [ 'name' => t("IP Address"), 'description' => t("The IP address of the computer the comment was posted from."), Loading Loading @@ -144,6 +148,10 @@ function comment_tokens($type, $tokens, array $data, array $options, BubbleableM $replacements[$original] = $comment->id(); break; case 'uuid': $replacements[$original] = $comment->uuid(); break; // Poster identity information for comments. case 'hostname': $replacements[$original] = $comment->getHostname(); Loading core/modules/comment/tests/src/Functional/CommentTokenReplaceTest.php +4 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,7 @@ public function testCommentTokenReplacement(): void { // Generate and test tokens. $tests = []; $tests['[comment:cid]'] = $comment->id(); $tests['[comment:uuid]'] = $comment->uuid(); $tests['[comment:hostname]'] = $comment->getHostname(); $tests['[comment:author]'] = Html::escape($comment->getAuthorName()); $tests['[comment:mail]'] = $this->adminUser->getEmail(); Loading @@ -91,6 +92,7 @@ public function testCommentTokenReplacement(): void { $tests['[comment:created:since]'] = \Drupal::service('date.formatter')->formatTimeDiffSince($comment->getCreatedTime(), ['langcode' => $language_interface->getId()]); $tests['[comment:changed:since]'] = \Drupal::service('date.formatter')->formatTimeDiffSince($comment->getChangedTimeAcrossTranslations(), ['langcode' => $language_interface->getId()]); $tests['[comment:parent:cid]'] = $comment->hasParentComment() ? $comment->getParentComment()->id() : NULL; $tests['[comment:parent:uuid]'] = $comment->hasParentComment() ? $comment->getParentComment()->uuid() : NULL; $tests['[comment:parent:title]'] = $parent_comment->getSubject(); $tests['[comment:entity]'] = Html::escape($node->getTitle()); // Test node specific tokens. Loading @@ -102,6 +104,7 @@ public function testCommentTokenReplacement(): void { $base_bubbleable_metadata = BubbleableMetadata::createFromObject($comment); $metadata_tests = []; $metadata_tests['[comment:cid]'] = $base_bubbleable_metadata; $metadata_tests['[comment:uuid]'] = $base_bubbleable_metadata; $metadata_tests['[comment:hostname]'] = $base_bubbleable_metadata; $bubbleable_metadata = clone $base_bubbleable_metadata; $bubbleable_metadata->addCacheableDependency($this->adminUser); Loading @@ -123,6 +126,7 @@ public function testCommentTokenReplacement(): void { $metadata_tests['[comment:changed:since]'] = $bubbleable_metadata->setCacheMaxAge(0); $bubbleable_metadata = clone $base_bubbleable_metadata; $metadata_tests['[comment:parent:cid]'] = $bubbleable_metadata->addCacheTags(['comment:1']); $metadata_tests['[comment:parent:uuid]'] = $bubbleable_metadata->addCacheTags(['comment:1']); $metadata_tests['[comment:parent:title]'] = $bubbleable_metadata; $bubbleable_metadata = clone $base_bubbleable_metadata; $metadata_tests['[comment:entity]'] = $bubbleable_metadata->addCacheTags(['node:2']); Loading core/modules/file/file.module +8 −0 Original line number Diff line number Diff line Loading @@ -473,6 +473,10 @@ function file_tokens($type, $tokens, array $data, array $options, BubbleableMeta $replacements[$original] = $file->id(); break; case 'uuid': $replacements[$original] = $file->uuid(); break; // Essential file data case 'name': $replacements[$original] = $file->getFilename(); Loading Loading @@ -552,6 +556,10 @@ function file_token_info() { 'name' => t("File ID"), 'description' => t("The unique ID of the uploaded file."), ]; $file['uuid'] = [ 'name' => t('UUID'), 'description' => t('The UUID of the uploaded file.'), ]; $file['name'] = [ 'name' => t("File name"), 'description' => t("The name of the file on disk."), Loading core/modules/file/tests/src/Functional/FileTokenReplaceTest.php +2 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ public function testFileTokenReplacement(): void { // Generate and test sanitized tokens. $tests = []; $tests['[file:fid]'] = $file->id(); $tests['[file:uuid]'] = $file->uuid(); $tests['[file:name]'] = Html::escape($file->getFilename()); $tests['[file:path]'] = Html::escape($file->getFileUri()); $tests['[file:mime]'] = Html::escape($file->getMimeType()); Loading @@ -68,6 +69,7 @@ public function testFileTokenReplacement(): void { $base_bubbleable_metadata = BubbleableMetadata::createFromObject($file); $metadata_tests = []; $metadata_tests['[file:fid]'] = $base_bubbleable_metadata; $metadata_tests['[file:uuid]'] = $base_bubbleable_metadata; $metadata_tests['[file:name]'] = $base_bubbleable_metadata; $metadata_tests['[file:path]'] = $base_bubbleable_metadata; $metadata_tests['[file:mime]'] = $base_bubbleable_metadata; Loading core/modules/node/node.tokens.inc +8 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,10 @@ function node_token_info() { 'name' => t("Content ID"), 'description' => t('The unique ID of the content item, or "node".'), ]; $node['uuid'] = [ 'name' => t('UUID'), 'description' => t('The UUID of the content item, or "node".'), ]; $node['vid'] = [ 'name' => t("Revision ID"), 'description' => t("The unique ID of the node's latest revision."), Loading Loading @@ -112,6 +116,10 @@ function node_tokens($type, $tokens, array $data, array $options, BubbleableMeta $replacements[$original] = $node->id(); break; case 'uuid': $replacements[$original] = $node->uuid(); break; case 'vid': $replacements[$original] = $node->getRevisionId(); break; Loading Loading
core/modules/comment/comment.tokens.inc +8 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,10 @@ function comment_token_info() { 'name' => t("Comment ID"), 'description' => t("The unique ID of the comment."), ]; $comment['uuid'] = [ 'name' => t('UUID'), 'description' => t("The UUID of the comment."), ]; $comment['hostname'] = [ 'name' => t("IP Address"), 'description' => t("The IP address of the computer the comment was posted from."), Loading Loading @@ -144,6 +148,10 @@ function comment_tokens($type, $tokens, array $data, array $options, BubbleableM $replacements[$original] = $comment->id(); break; case 'uuid': $replacements[$original] = $comment->uuid(); break; // Poster identity information for comments. case 'hostname': $replacements[$original] = $comment->getHostname(); Loading
core/modules/comment/tests/src/Functional/CommentTokenReplaceTest.php +4 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,7 @@ public function testCommentTokenReplacement(): void { // Generate and test tokens. $tests = []; $tests['[comment:cid]'] = $comment->id(); $tests['[comment:uuid]'] = $comment->uuid(); $tests['[comment:hostname]'] = $comment->getHostname(); $tests['[comment:author]'] = Html::escape($comment->getAuthorName()); $tests['[comment:mail]'] = $this->adminUser->getEmail(); Loading @@ -91,6 +92,7 @@ public function testCommentTokenReplacement(): void { $tests['[comment:created:since]'] = \Drupal::service('date.formatter')->formatTimeDiffSince($comment->getCreatedTime(), ['langcode' => $language_interface->getId()]); $tests['[comment:changed:since]'] = \Drupal::service('date.formatter')->formatTimeDiffSince($comment->getChangedTimeAcrossTranslations(), ['langcode' => $language_interface->getId()]); $tests['[comment:parent:cid]'] = $comment->hasParentComment() ? $comment->getParentComment()->id() : NULL; $tests['[comment:parent:uuid]'] = $comment->hasParentComment() ? $comment->getParentComment()->uuid() : NULL; $tests['[comment:parent:title]'] = $parent_comment->getSubject(); $tests['[comment:entity]'] = Html::escape($node->getTitle()); // Test node specific tokens. Loading @@ -102,6 +104,7 @@ public function testCommentTokenReplacement(): void { $base_bubbleable_metadata = BubbleableMetadata::createFromObject($comment); $metadata_tests = []; $metadata_tests['[comment:cid]'] = $base_bubbleable_metadata; $metadata_tests['[comment:uuid]'] = $base_bubbleable_metadata; $metadata_tests['[comment:hostname]'] = $base_bubbleable_metadata; $bubbleable_metadata = clone $base_bubbleable_metadata; $bubbleable_metadata->addCacheableDependency($this->adminUser); Loading @@ -123,6 +126,7 @@ public function testCommentTokenReplacement(): void { $metadata_tests['[comment:changed:since]'] = $bubbleable_metadata->setCacheMaxAge(0); $bubbleable_metadata = clone $base_bubbleable_metadata; $metadata_tests['[comment:parent:cid]'] = $bubbleable_metadata->addCacheTags(['comment:1']); $metadata_tests['[comment:parent:uuid]'] = $bubbleable_metadata->addCacheTags(['comment:1']); $metadata_tests['[comment:parent:title]'] = $bubbleable_metadata; $bubbleable_metadata = clone $base_bubbleable_metadata; $metadata_tests['[comment:entity]'] = $bubbleable_metadata->addCacheTags(['node:2']); Loading
core/modules/file/file.module +8 −0 Original line number Diff line number Diff line Loading @@ -473,6 +473,10 @@ function file_tokens($type, $tokens, array $data, array $options, BubbleableMeta $replacements[$original] = $file->id(); break; case 'uuid': $replacements[$original] = $file->uuid(); break; // Essential file data case 'name': $replacements[$original] = $file->getFilename(); Loading Loading @@ -552,6 +556,10 @@ function file_token_info() { 'name' => t("File ID"), 'description' => t("The unique ID of the uploaded file."), ]; $file['uuid'] = [ 'name' => t('UUID'), 'description' => t('The UUID of the uploaded file.'), ]; $file['name'] = [ 'name' => t("File name"), 'description' => t("The name of the file on disk."), Loading
core/modules/file/tests/src/Functional/FileTokenReplaceTest.php +2 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ public function testFileTokenReplacement(): void { // Generate and test sanitized tokens. $tests = []; $tests['[file:fid]'] = $file->id(); $tests['[file:uuid]'] = $file->uuid(); $tests['[file:name]'] = Html::escape($file->getFilename()); $tests['[file:path]'] = Html::escape($file->getFileUri()); $tests['[file:mime]'] = Html::escape($file->getMimeType()); Loading @@ -68,6 +69,7 @@ public function testFileTokenReplacement(): void { $base_bubbleable_metadata = BubbleableMetadata::createFromObject($file); $metadata_tests = []; $metadata_tests['[file:fid]'] = $base_bubbleable_metadata; $metadata_tests['[file:uuid]'] = $base_bubbleable_metadata; $metadata_tests['[file:name]'] = $base_bubbleable_metadata; $metadata_tests['[file:path]'] = $base_bubbleable_metadata; $metadata_tests['[file:mime]'] = $base_bubbleable_metadata; Loading
core/modules/node/node.tokens.inc +8 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,10 @@ function node_token_info() { 'name' => t("Content ID"), 'description' => t('The unique ID of the content item, or "node".'), ]; $node['uuid'] = [ 'name' => t('UUID'), 'description' => t('The UUID of the content item, or "node".'), ]; $node['vid'] = [ 'name' => t("Revision ID"), 'description' => t("The unique ID of the node's latest revision."), Loading Loading @@ -112,6 +116,10 @@ function node_tokens($type, $tokens, array $data, array $options, BubbleableMeta $replacements[$original] = $node->id(); break; case 'uuid': $replacements[$original] = $node->uuid(); break; case 'vid': $replacements[$original] = $node->getRevisionId(); break; Loading