summaryrefslogtreecommitdiff
path: root/src/PluginLoader.php
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2022-03-06 00:48:14 +0100
committerDaniel Weipert <code@drogueronin.de>2022-03-06 00:48:14 +0100
commitb2a86c7df7d5a473e80034832a01b21444fa50e6 (patch)
tree2b18e08124ff3e8602a20ba27fef3ae4d066cc28 /src/PluginLoader.php
parentdf428380e288db75b41ace5d6274f44916517f9f (diff)
Refactor
Diffstat (limited to 'src/PluginLoader.php')
-rw-r--r--src/PluginLoader.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/PluginLoader.php b/src/PluginLoader.php
new file mode 100644
index 0000000..c8da5fd
--- /dev/null
+++ b/src/PluginLoader.php
@@ -0,0 +1,29 @@
+<?php
+
+namespace FlatFileForms;
+
+class PluginLoader
+{
+ public function __construct()
+ {
+ /**@var Utilities $utilities*/
+ global $utilities;
+
+ $pluginsDirectoryPath = $_ENV['app']['pluginsFolderPath'];
+
+ spl_autoload_register(function ($classname) use ($pluginsDirectoryPath) {
+ $classname = str_replace('FlatFileForms\\Plugins\\', '', $classname);
+
+ require_once
+ $pluginsDirectoryPath . '/' .
+ str_replace('\\', '/', $classname) .
+ '.php';
+ });
+
+ $pluginDirectories = $utilities->scandir($pluginsDirectoryPath);
+ foreach ($pluginDirectories as $directory) {
+ $pluginClass = 'FlatFileForms\\Plugins\\' . $directory . '\\Plugin';
+ $plugin = new $pluginClass();
+ }
+ }
+}