Loading core/modules/views/src/Plugin/views/PluginBase.php +4 −1 Changes for core/modules/views/src/Plugin/views/PluginBase.php: 4 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -382,7 +382,10 @@ protected function viewsTokenReplace($text, $tokens) { assert('preg_match(\'/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/\', $key) === 1', 'Tokens need to be valid Twig variables.'); $token_array = array($key => $token_array); } $twig_tokens[$top] = $token_array; if (!isset($twig_tokens[$top])) { $twig_tokens[$top] = []; } $twig_tokens[$top] += $token_array; } } Loading core/modules/views/src/Tests/Plugin/PluginBaseTest.php +14 −0 Changes for core/modules/views/src/Tests/Plugin/PluginBaseTest.php: 14 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -43,6 +43,20 @@ public function testViewsTokenReplace() { $this->assertIdentical($result, 'en means English'); } /** * Test that the token replacement in views works correctly with dots. */ public function testViewsTokenReplaceWithDots() { $text = '{{ argument.first }} comes before {{ argument.second }}'; $tokens = ['{{ argument.first }}' => 'first', '{{ argument.second }}' => 'second']; $result = \Drupal::service('renderer')->executeInRenderContext(new RenderContext(), function () use ($text, $tokens) { return $this->testPluginBase->viewsTokenReplace($text, $tokens); }); $this->assertIdentical($result, 'first comes before second'); } /** * Tests viewsTokenReplace without any twig tokens. */ Loading Loading
core/modules/views/src/Plugin/views/PluginBase.php +4 −1 Changes for core/modules/views/src/Plugin/views/PluginBase.php: 4 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -382,7 +382,10 @@ protected function viewsTokenReplace($text, $tokens) { assert('preg_match(\'/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/\', $key) === 1', 'Tokens need to be valid Twig variables.'); $token_array = array($key => $token_array); } $twig_tokens[$top] = $token_array; if (!isset($twig_tokens[$top])) { $twig_tokens[$top] = []; } $twig_tokens[$top] += $token_array; } } Loading
core/modules/views/src/Tests/Plugin/PluginBaseTest.php +14 −0 Changes for core/modules/views/src/Tests/Plugin/PluginBaseTest.php: 14 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -43,6 +43,20 @@ public function testViewsTokenReplace() { $this->assertIdentical($result, 'en means English'); } /** * Test that the token replacement in views works correctly with dots. */ public function testViewsTokenReplaceWithDots() { $text = '{{ argument.first }} comes before {{ argument.second }}'; $tokens = ['{{ argument.first }}' => 'first', '{{ argument.second }}' => 'second']; $result = \Drupal::service('renderer')->executeInRenderContext(new RenderContext(), function () use ($text, $tokens) { return $this->testPluginBase->viewsTokenReplace($text, $tokens); }); $this->assertIdentical($result, 'first comes before second'); } /** * Tests viewsTokenReplace without any twig tokens. */ Loading