You are here

public function TestController::tokenReplaceWithoutPassedBubbleableMetadata in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/tests/modules/token_test/src/Controller/TestController.php \Drupal\token_test\Controller\TestController::tokenReplaceWithoutPassedBubbleableMetadata()

Provides a token replacement with a node as well as the current user.

This controller is for testing the token service's fallback behavior of applying collected metadata to the currently active render context when an explicit bubbleable metadata object isn't passed in.

Parameters

\Drupal\node\NodeInterface $node: The node.

Return value

array The render array.

1 string reference to 'TestController::tokenReplaceWithoutPassedBubbleableMetadata'
token_test.routing.yml in core/modules/system/tests/modules/token_test/token_test.routing.yml
core/modules/system/tests/modules/token_test/token_test.routing.yml

File

core/modules/system/tests/modules/token_test/src/Controller/TestController.php, line 80
Contains \Drupal\token_test\Controller\TestController.

Class

TestController
Provides a test controller for token replacement.

Namespace

Drupal\token_test\Controller

Code

public function tokenReplaceWithoutPassedBubbleableMetadata(NodeInterface $node) {
  $build['#markup'] = $this->token
    ->replace('Tokens: [node:nid] [current-user:uid]', [
    'node' => $node,
  ], []);
  return $build;
}