function TestController::tokenReplaceWithoutPassedBubbleableMetadata

Same name in other branches
  1. 9 core/modules/system/tests/modules/token_test/src/Controller/TestController.php \Drupal\token_test\Controller\TestController::tokenReplaceWithoutPassedBubbleableMetadata()
  2. 8.9.x core/modules/system/tests/modules/token_test/src/Controller/TestController.php \Drupal\token_test\Controller\TestController::tokenReplaceWithoutPassedBubbleableMetadata()
  3. 11.x 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 74

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.