Issue #2718717 by damiankloip: Assertion error when paging a view using an entity autocomplete exposed filter
parent
4ad7ddb35a
commit
3f52754e42
|
@ -373,7 +373,8 @@ abstract class PluginBase extends ComponentPluginBase implements ContainerFactor
|
|||
assert('preg_match(\'/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/\', $top) === 1', 'Tokens need to be valid Twig variables.');
|
||||
$token_array = array(array_pop($parts) => $replacement);
|
||||
foreach (array_reverse($parts) as $key) {
|
||||
assert('preg_match(\'/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/\', $key) === 1', 'Tokens need to be valid Twig variables.');
|
||||
// The key could also be numeric (array index) so allow that.
|
||||
assert('is_numeric($key) || (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);
|
||||
}
|
||||
if (!isset($twig_tokens[$top])) {
|
||||
|
|
|
@ -55,6 +55,16 @@ class PluginBaseTest extends KernelTestBase {
|
|||
});
|
||||
|
||||
$this->assertIdentical($result, 'first comes before second');
|
||||
|
||||
// Test tokens with numeric indexes.
|
||||
$text = '{{ argument.0.first }} comes before {{ argument.1.second }}';
|
||||
$tokens = ['{{ argument.0.first }}' => 'first', '{{ argument.1.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');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue