public function TestController::tokenReplaceWithoutPassedBubbleableMetadata in Drupal 8
Same name and namespace in other branches
- 9 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\ControllerCode
public function tokenReplaceWithoutPassedBubbleableMetadata(NodeInterface $node) {
$build['#markup'] = $this->token
->replace('Tokens: [node:nid] [current-user:uid]', [
'node' => $node,
], []);
return $build;
}