diff --git a/src/Extension/DefaultExtension.php b/src/Extension/DefaultExtension.php index 88390b941..dc1036bbd 100644 --- a/src/Extension/DefaultExtension.php +++ b/src/Extension/DefaultExtension.php @@ -6,14 +6,27 @@ class DefaultExtension extends Base { + /** + * @var \Smarty\Smarty + */ + private $smarty; + private $modifiers = []; private $functionHandlers = []; private $blockHandlers = []; + public function __construct(\Smarty\Smarty $smarty) { + $this->smarty = $smarty; + } + public function getModifierCompiler(string $modifier): ?\Smarty\Compile\Modifier\ModifierCompilerInterface { + if($this->smarty->getRegisteredPlugin(\Smarty\Smarty::PLUGIN_MODIFIER, $modifier) ?? $this->smarty->getRegisteredPlugin(\Smarty\Smarty::PLUGIN_MODIFIERCOMPILER, $modifier)) { + return null; + } + if (isset($this->modifiers[$modifier])) { return $this->modifiers[$modifier]; } @@ -53,7 +66,12 @@ public function getModifierCompiler(string $modifier): ?\Smarty\Compile\Modifier } public function getModifierCallback(string $modifierName) { - switch ($modifierName) { + + if ($this->smarty->getRegisteredPlugin(\Smarty\Smarty::PLUGIN_MODIFIER, $modifierName)){ + return null; + } + + switch ($modifierName) { case 'capitalize': return [$this, 'smarty_modifier_capitalize']; case 'count': return [$this, 'smarty_modifier_count']; case 'date_format': return [$this, 'smarty_modifier_date_format']; diff --git a/src/Smarty.php b/src/Smarty.php index 339103247..d8ca1ed24 100644 --- a/src/Smarty.php +++ b/src/Smarty.php @@ -526,7 +526,7 @@ public function __construct() { $this->BCPluginsAdapter = new BCPluginsAdapter($this); $this->extensions[] = new CoreExtension(); - $this->extensions[] = new DefaultExtension(); + $this->extensions[] = new DefaultExtension($this); $this->extensions[] = $this->BCPluginsAdapter; $this->cacheResource = new File();