[TASK] DotsToBracketsViewHelper: Add option to render unquoted parts

This commit is contained in:
Philipp Dieter 2021-06-30 23:52:21 +02:00
parent 3dbd981f97
commit ccb3141487

View File

@ -13,9 +13,18 @@ class DotsToBracketsViewHelper extends AbstractViewHelper
RenderingContextInterface $renderingContext RenderingContextInterface $renderingContext
) { ) {
$parts = explode('.', $renderChildrenClosure()); $parts = explode('.', $renderChildrenClosure());
$_ = '[\''; $_ = '';
$_ .= implode('\'][\'', $parts); foreach ($parts as $part) {
$_ .= '\']'; $_ .= '[';
if (substr($part, 0, 1) === '#') {
$_ .= substr($part, 1);
} else {
$_ .= '\'';
$_ .= $part;
$_ .= '\'';
}
$_ .= ']';
}
return $_; return $_;
} }
} }