summaryrefslogtreecommitdiff
path: root/src/Compile/FunctionCallCompiler.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Compile/FunctionCallCompiler.php')
-rw-r--r--src/Compile/FunctionCallCompiler.php30
1 files changed, 17 insertions, 13 deletions
diff --git a/src/Compile/FunctionCallCompiler.php b/src/Compile/FunctionCallCompiler.php
index 107dd98b..3ce50da2 100644
--- a/src/Compile/FunctionCallCompiler.php
+++ b/src/Compile/FunctionCallCompiler.php
@@ -3,24 +3,18 @@
* Smarty Internal Plugin Compile Registered Function
* Compiles code for the execution of a registered function
*
-
-
* @author Uwe Tews
*/
namespace Smarty\Compile;
use Smarty\Compiler\Template;
-use Smarty\CompilerException;
+use Smarty\FunctionHandler\AttributeFunctionHandlerInterface;
/**
* Smarty Internal Plugin Compile Registered Function Class
- *
-
-
*/
class FunctionCallCompiler extends Base {
-
/**
* Attribute definition: Overwrites base class.
*
@@ -51,16 +45,26 @@ class FunctionCallCompiler extends Base {
*/
public function compile($args, Template $compiler, $parameter = [], $tag = null, $function = null): string
{
+ if ($functionHandler = $compiler->getSmarty()->getFunctionHandler($function)) {
- // check and get attributes
- $_attr = $this->getAttributes($compiler, $args);
- unset($_attr['nocache']);
+ $attribute_overrides = [];
- $_paramsArray = $this->formatParamsArray($_attr);
- $_params = 'array(' . implode(',', $_paramsArray) . ')';
+ if ($functionHandler instanceof AttributeFunctionHandlerInterface) {
+ $attribute_overrides = $functionHandler->getSupportedAttributes();
+ }
+ // check and get attributes
+ $_attr = (new AttributeCompiler(
+ $attribute_overrides['required_attributes'] ?? $this->required_attributes,
+ $attribute_overrides['optional_attributes'] ?? $this->optional_attributes,
+ $attribute_overrides['shorttag_order'] ?? $this->shorttag_order,
+ $attribute_overrides['option_flags'] ?? $this->option_flags
+ ))->getAttributes($compiler, $args);
- if ($functionHandler = $compiler->getSmarty()->getFunctionHandler($function)) {
+ unset($_attr['nocache']);
+
+ $_paramsArray = $this->formatParamsArray($_attr);
+ $_params = 'array(' . implode(',', $_paramsArray) . ')';
// not cacheable?
$compiler->tag_nocache = $compiler->tag_nocache || !$functionHandler->isCacheable();