From 1ff5c35de5dbd70a782875a91dd2232fd01b002b Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 14:38:04 +0200 Subject: Adding upstream version 0.10.1. Signed-off-by: Daniel Baumann --- vendor/ipl/stdlib/src/Plugins.php | 95 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 vendor/ipl/stdlib/src/Plugins.php (limited to 'vendor/ipl/stdlib/src/Plugins.php') diff --git a/vendor/ipl/stdlib/src/Plugins.php b/vendor/ipl/stdlib/src/Plugins.php new file mode 100644 index 0000000..a5dbb77 --- /dev/null +++ b/vendor/ipl/stdlib/src/Plugins.php @@ -0,0 +1,95 @@ +pluginLoaders[$type]); + } + + /** + * Add a plugin loader for the given type + * + * @param string $type + * @param PluginLoader|string $loaderOrNamespace + * @param string $postfix + * + * @return $this + */ + public function addPluginLoader($type, $loaderOrNamespace, $postfix = '') + { + $loader = static::wantPluginLoader($loaderOrNamespace, $postfix); + + if (! isset($this->pluginLoaders[$type])) { + $this->pluginLoaders[$type] = []; + } + + array_unshift($this->pluginLoaders[$type], $loader); + + return $this; + } + + /** + * Load the class file of the given plugin + * + * @param string $type + * @param string $name + * + * @return string|false + */ + public function loadPlugin($type, $name) + { + if ($this->hasPluginLoader($type)) { + /** @var PluginLoader $loader */ + foreach ($this->pluginLoaders[$type] as $loader) { + $class = $loader->load($name); + if ($class) { + return $class; + } + } + } + + return false; + } + + protected function addDefaultPluginLoader($type, $loaderOrNamespace, $postfix) + { + $this->pluginLoaders[$type][] = static::wantPluginLoader($loaderOrNamespace, $postfix); + + return $this; + } +} -- cgit v1.2.3