mirror of
https://github.com/billz/raspap-webgui.git
synced 2025-03-01 10:31:47 +00:00
53 lines
1.3 KiB
PHP
53 lines
1.3 KiB
PHP
<?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;
|
|
}
|
|
|
|
}
|
|
|