Fixed modifiercompiler handling multiple/chained modifiers

This commit is contained in:
Simon Wisselink
2023-01-09 09:53:15 +01:00
parent 861aafa92c
commit c5de83b09f

View File

@@ -50,29 +50,27 @@ class ModifierCompiler extends Base {
) { ) {
if ($handler = $compiler->getModifierCompiler($modifier)) { if ($handler = $compiler->getModifierCompiler($modifier)) {
return $handler->compile($single_modifier, $compiler); $output = $handler->compile($single_modifier, $compiler);
} elseif ($compiler->getSmarty()->getModifierCallback($modifier)) { } elseif ($compiler->getSmarty()->getModifierCallback($modifier)) {
return sprintf( $output = sprintf(
'$_smarty_tpl->smarty->getModifierCallback(%s)(%s)', '$_smarty_tpl->smarty->getModifierCallback(%s)(%s)',
var_export($modifier, true), var_export($modifier, true),
$params $params
); );
} elseif ($callback = $compiler->getPluginFromDefaultHandler($modifier, \Smarty\Smarty::PLUGIN_MODIFIERCOMPILER)) { } elseif ($callback = $compiler->getPluginFromDefaultHandler($modifier, \Smarty\Smarty::PLUGIN_MODIFIERCOMPILER)) {
$wrapper = new \Smarty\Compile\Modifier\BCPluginWrapper($callback); $output = (new \Smarty\Compile\Modifier\BCPluginWrapper($callback))->compile($single_modifier, $compiler);
return $wrapper->compile($single_modifier, $compiler);
} elseif ($function = $compiler->getPluginFromDefaultHandler($modifier, \Smarty\Smarty::PLUGIN_MODIFIER)) { } elseif ($function = $compiler->getPluginFromDefaultHandler($modifier, \Smarty\Smarty::PLUGIN_MODIFIER)) {
if (!is_array($function)) { if (!is_array($function)) {
return "{$function}({$params})"; $output = "{$function}({$params})";
} else {
$operator = is_object($function[0]) ? '->' : '::';
$output = $function[0] . $operator . $function[1] . '(' . $params . ')';
} }
$operator = is_object($function[0]) ? '->' : '::';
return $function[0] . $operator . $function[1] . '(' . $params . ')';
} else { } else {
$compiler->trigger_template_error("unknown modifier '{$modifier}'", null, true); $compiler->trigger_template_error("unknown modifier '{$modifier}'", null, true);
} }
} }
} }
return $output; return $output;
} }