getSmarty()->security_policy) || $compiler->getSmarty()->security_policy->isTrustedModifier($modifier, $compiler) ) { if ($handler = $compiler->getModifierCompiler($modifier)) { $output = $handler->compile($modifier_params, $compiler); } elseif ($compiler->getSmarty()->getModifierCallback($modifier)) { $output = sprintf( '$_smarty_tpl->getSmarty()->getModifierCallback(%s)(%s)', var_export($modifier, true), $params ); } elseif ($callback = $compiler->getPluginFromDefaultHandler($modifier, \Smarty\Smarty::PLUGIN_MODIFIERCOMPILER)) { $output = (new \Smarty\Compile\Modifier\BCPluginWrapper($callback))->compile($modifier_params, $compiler); } elseif ($function = $compiler->getPluginFromDefaultHandler($modifier, \Smarty\Smarty::PLUGIN_MODIFIER)) { if (!is_array($function)) { $output = "{$function}({$params})"; } else { $operator = is_object($function[0]) ? '->' : '::'; $output = $function[0] . $operator . $function[1] . '(' . $params . ')'; } } else { $compiler->trigger_template_error("unknown modifier '{$modifier}'", null, true); } } } return (string)$output; } /** * Wether this class will be able to compile the given modifier. * @param string $modifier * @param Template $compiler * * @return bool * @throws CompilerException */ public function canCompileForModifier(string $modifier, \Smarty\Compiler\Template $compiler): bool { return $compiler->getModifierCompiler($modifier) || $compiler->getSmarty()->getModifierCallback($modifier) || $compiler->getPluginFromDefaultHandler($modifier, \Smarty\Smarty::PLUGIN_MODIFIERCOMPILER) || $compiler->getPluginFromDefaultHandler($modifier, \Smarty\Smarty::PLUGIN_MODIFIER); } }