diff --git a/core/modules/views/src/Plugin/views/PluginBase.php b/core/modules/views/src/Plugin/views/PluginBase.php index c2d9f0f..3f0729f 100644 --- a/core/modules/views/src/Plugin/views/PluginBase.php +++ b/core/modules/views/src/Plugin/views/PluginBase.php @@ -404,6 +404,9 @@ function ($children, $elements) { return (string) $this->getRenderer()->renderPlain($build); } + else { + return $text; + } } /** diff --git a/core/modules/views/src/Plugin/views/area/TokenizeAreaPluginBase.php b/core/modules/views/src/Plugin/views/area/TokenizeAreaPluginBase.php index 18a9bd5..4460a9a 100644 --- a/core/modules/views/src/Plugin/views/area/TokenizeAreaPluginBase.php +++ b/core/modules/views/src/Plugin/views/area/TokenizeAreaPluginBase.php @@ -53,12 +53,12 @@ public function tokenForm(&$form, FormStateInterface $form_state) { // Get a list of the available fields and arguments for token replacement. $options = array(); foreach ($this->view->display_handler->getHandlers('field') as $field => $handler) { - $options[t('Fields')]["{{ $field }}"] = $handler->adminLabel(); + $options[(string) t('Fields')]["{{ $field }}"] = $handler->adminLabel(); } foreach ($this->view->display_handler->getHandlers('argument') as $arg => $handler) { - $options[t('Arguments')]["{{ arguments.$arg }}"] = $this->t('@argument title', array('@argument' => $handler->adminLabel())); - $options[t('Arguments')]["{{ raw_arguments.$arg }}"] = $this->t('@argument input', array('@argument' => $handler->adminLabel())); + $options[(string) t('Arguments')]["{{ arguments.$arg }}"] = $this->t('@argument title', array('@argument' => $handler->adminLabel())); + $options[(string) t('Arguments')]["{{ raw_arguments.$arg }}"] = $this->t('@argument input', array('@argument' => $handler->adminLabel())); } if (!empty($options)) { diff --git a/core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php b/core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php index de1818d..53cccf6 100644 --- a/core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php +++ b/core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php @@ -376,8 +376,8 @@ protected function getTokenHelp() { foreach ($this->view->display_handler->getHandlers('argument') as $arg => $handler) { /** @var \Drupal\views\Plugin\views\argument\ArgumentPluginBase $handler */ - $options[t('Arguments')]["{{ arguments.$arg }}"] = $this->t('@argument title', array('@argument' => $handler->adminLabel())); - $options[t('Arguments')]["{{ raw_arguments.$arg }}"] = $this->t('@argument input', array('@argument' => $handler->adminLabel())); + $options[(string) t('Arguments')]["{{ arguments.$arg }}"] = $this->t('@argument title', array('@argument' => $handler->adminLabel())); + $options[(string) t('Arguments')]["{{ raw_arguments.$arg }}"] = $this->t('@argument input', array('@argument' => $handler->adminLabel())); } // We have some options, so make a list. diff --git a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php index 96fbe9d..bac0dd8 100644 --- a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php +++ b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php @@ -1726,8 +1726,8 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { $options = array(); foreach ($this->view->display_handler->getHandlers('argument') as $arg => $handler) { - $options[t('Arguments')]["{{ arguments.$arg }}"] = $this->t('@argument title', array('@argument' => $handler->adminLabel())); - $options[t('Arguments')]["{{ raw_arguments.$arg }}"] = $this->t('@argument input', array('@argument' => $handler->adminLabel())); + $options[(string) t('Arguments')]["{{ arguments.$arg }}"] = $this->t('@argument title', array('@argument' => $handler->adminLabel())); + $options[(string) t('Arguments')]["{{ raw_arguments.$arg }}"] = $this->t('@argument input', array('@argument' => $handler->adminLabel())); } // Default text. diff --git a/core/modules/views/src/Plugin/views/field/FieldPluginBase.php b/core/modules/views/src/Plugin/views/field/FieldPluginBase.php index 0a86fc9..17f1763 100644 --- a/core/modules/views/src/Plugin/views/field/FieldPluginBase.php +++ b/core/modules/views/src/Plugin/views/field/FieldPluginBase.php @@ -869,8 +869,8 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { $options[t('Fields')]["{{ {$this->options['id']} }}"] = substr(strrchr($this->adminLabel(), ":"), 2 ); foreach ($this->view->display_handler->getHandlers('argument') as $arg => $handler) { - $options[t('Arguments')]["{{ arguments.$arg }}"] = $this->t('@argument title', array('@argument' => $handler->adminLabel())); - $options[t('Arguments')]["{{ raw_arguments.$arg }}"] = $this->t('@argument input', array('@argument' => $handler->adminLabel())); + $options[(string) t('Arguments')]["{{ arguments.$arg }}"] = $this->t('@argument title', array('@argument' => $handler->adminLabel())); + $options[(string) t('Arguments')]["{{ raw_arguments.$arg }}"] = $this->t('@argument input', array('@argument' => $handler->adminLabel())); } $this->documentSelfTokens($options[t('Fields')]); diff --git a/core/modules/views/src/Tests/Handler/FieldKernelTest.php b/core/modules/views/src/Tests/Handler/FieldKernelTest.php index aabb813..109314b 100644 --- a/core/modules/views/src/Tests/Handler/FieldKernelTest.php +++ b/core/modules/views/src/Tests/Handler/FieldKernelTest.php @@ -193,7 +193,7 @@ public function testArgumentTokens() { return $name_field_0->advancedRender($row); }); - $this->assertFalse(strpos((string) $output, 'views_test_data_test_pre_render_function executed') !== FALSE); + $this->assertFalse(strpos((string) $output, 'views_test_data_test_pre_render_function executed') !== FALSE, 'Ensure that the pre_render function was not executed'); $this->assertEqual('%1 !1', (string) $output, "Ensure that old style placeholders aren't replaced"); // This time use new style tokens but ensure that we still don't allow @@ -207,8 +207,8 @@ public function testArgumentTokens() { return $name_field_0->advancedRender($row); }); - $this->assertFalse(strpos((string) $output, 'views_test_data_test_pre_render_function executed') !== FALSE); - $this->assertEqual(' ', (string) $output, "Ensure that old style placeholders aren't replaced"); + $this->assertFalse(strpos((string) $output, 'views_test_data_test_pre_render_function executed') !== FALSE, 'Ensure that the pre_render function was not executed'); + $this->assertEqual(' ', (string) $output, 'Ensure that new style placeholders are replaced'); } /** diff --git a/core/modules/views/src/Tests/Plugin/PluginBaseTest.php b/core/modules/views/src/Tests/Plugin/PluginBaseTest.php index f4b5c2d..c5d69ab 100644 --- a/core/modules/views/src/Tests/Plugin/PluginBaseTest.php +++ b/core/modules/views/src/Tests/Plugin/PluginBaseTest.php @@ -43,6 +43,16 @@ public function testViewsTokenReplace() { $this->assertIdentical($result, 'en means English'); } + /** + * Tests viewsTokenReplace without any twig tokens. + */ + public function testViewsTokenReplaceWithTwigTokens() { + $text = 'Just some text'; + $tokens = []; + $result = $this->testPluginBase->viewsTokenReplace($text, $tokens); + $this->assertIdentical($result, 'Just some text'); + } + } /**