mirror of
https://github.com/billz/raspap-webgui.git
synced 2025-03-01 10:31:47 +00:00
Initial commit
This commit is contained in:
parent
89c4f16e45
commit
247b35b254
52
src/RaspAP/Plugins/PluginInstaller.php
Normal file
52
src/RaspAP/Plugins/PluginInstaller.php
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plugin Installer class
|
||||||
|
*
|
||||||
|
* @description Class to handle installation of user plugins
|
||||||
|
* @author Bill Zimmerman <billzimmerman@gmail.com>
|
||||||
|
* @license https://github.com/raspap/raspap-webgui/blob/master/LICENSE
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace RaspAP\Plugins;
|
||||||
|
|
||||||
|
class PluginInstaller
|
||||||
|
{
|
||||||
|
private static $instance = null;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->pluginPath = 'plugins';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns a single instance of PluginInstaller
|
||||||
|
public static function getInstance(): PluginInstaller
|
||||||
|
{
|
||||||
|
if (self::$instance === null) {
|
||||||
|
self::$instance = new PluginInstaller();
|
||||||
|
}
|
||||||
|
return self::$instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPlugins(): array
|
||||||
|
{
|
||||||
|
$plugins = [];
|
||||||
|
if (file_exists($this->pluginPath)) {
|
||||||
|
$directories = scandir($this->pluginPath);
|
||||||
|
|
||||||
|
foreach ($directories as $directory) {
|
||||||
|
$pluginClass = "RaspAP\\Plugins\\$directory\\$directory";
|
||||||
|
$pluginFile = $this->pluginPath . "/$directory/$directory.php";
|
||||||
|
|
||||||
|
if (file_exists($pluginFile) && class_exists($pluginClass)) {
|
||||||
|
$plugins[] = $pluginClass;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $plugins;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user