aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/smarty/smarty/src/Runtime/DefaultPluginHandlerRuntime.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/smarty/smarty/src/Runtime/DefaultPluginHandlerRuntime.php')
-rw-r--r--vendor/smarty/smarty/src/Runtime/DefaultPluginHandlerRuntime.php73
1 files changed, 73 insertions, 0 deletions
diff --git a/vendor/smarty/smarty/src/Runtime/DefaultPluginHandlerRuntime.php b/vendor/smarty/smarty/src/Runtime/DefaultPluginHandlerRuntime.php
new file mode 100644
index 000000000..f3be85ca6
--- /dev/null
+++ b/vendor/smarty/smarty/src/Runtime/DefaultPluginHandlerRuntime.php
@@ -0,0 +1,73 @@
+<?php
+
+namespace Smarty\Runtime;
+
+use Smarty\Exception;
+
+class DefaultPluginHandlerRuntime {
+
+ /**
+ * @var callable
+ */
+ private $defaultPluginHandler;
+
+ public function __construct(?callable $defaultPluginHandler = null) {
+ $this->defaultPluginHandler = $defaultPluginHandler;
+ }
+
+ public function hasPlugin($tag, $plugin_type): bool {
+ if ($this->defaultPluginHandler === null) {
+ return false;
+ }
+
+ $callback = null;
+
+ // these are not used here
+ $script = null;
+ $cacheable = null;
+
+ return (\call_user_func_array(
+ $this->defaultPluginHandler,
+ [
+ $tag,
+ $plugin_type,
+ null, // This used to pass $this->template, but this parameter has been removed in 5.0
+ &$callback,
+ &$script,
+ &$cacheable,
+ ]
+ ) && $callback);
+ }
+
+ /**
+ * @throws Exception
+ */
+ public function getCallback($tag, $plugin_type) {
+
+ if ($this->defaultPluginHandler === null) {
+ return false;
+ }
+
+ $callback = null;
+
+ // these are not used here
+ $script = null;
+ $cacheable = null;
+
+ if (\call_user_func_array(
+ $this->defaultPluginHandler,
+ [
+ $tag,
+ $plugin_type,
+ null, // This used to pass $this->template, but this parameter has been removed in 5.0
+ &$callback,
+ &$script,
+ &$cacheable,
+ ]
+ ) && $callback) {
+ return $callback;
+ }
+ throw new Exception("Default plugin handler: Returned callback for '{$tag}' not callable at runtime");
+ }
+
+} \ No newline at end of file