fetchpluginlist method
This commit is contained in:
parent
df65f9f2cc
commit
03da64decb
@ -36,6 +36,10 @@ class PluginManager {
|
|||||||
|
|
||||||
$this->pluginMenu = new PluginMenu($maniaControl);
|
$this->pluginMenu = new PluginMenu($maniaControl);
|
||||||
$this->maniaControl->configurator->addMenu($this->pluginMenu);
|
$this->maniaControl->configurator->addMenu($this->pluginMenu);
|
||||||
|
|
||||||
|
/*$this->fetchPluginList(function ($data) {
|
||||||
|
var_dump($data);
|
||||||
|
});*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -189,35 +193,35 @@ class PluginManager {
|
|||||||
$classesBefore = get_declared_classes();
|
$classesBefore = get_declared_classes();
|
||||||
$this->loadPluginFiles($pluginsDirectory);
|
$this->loadPluginFiles($pluginsDirectory);
|
||||||
$classesAfter = get_declared_classes();
|
$classesAfter = get_declared_classes();
|
||||||
|
|
||||||
$newClasses = array_diff($classesAfter, $classesBefore);
|
$newClasses = array_diff($classesAfter, $classesBefore);
|
||||||
foreach($newClasses as $className) {
|
foreach($newClasses as $className) {
|
||||||
if (!$this->isPluginClass($className)) {
|
if (!$this->isPluginClass($className)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->addPluginClass($className);
|
$this->addPluginClass($className);
|
||||||
$className::prepare($this->maniaControl);
|
$className::prepare($this->maniaControl);
|
||||||
|
|
||||||
if ($this->isPluginActive($className)) {
|
if ($this->isPluginActive($className)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!$this->getSavedPluginStatus($className)) {
|
if (!$this->getSavedPluginStatus($className)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->activatePlugin($className);
|
$this->activatePlugin($className);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load all Plugin Files from the Directory
|
* Load all Plugin Files from the Directory
|
||||||
*
|
*
|
||||||
* @param string $directory
|
* @param string $directory
|
||||||
*/
|
*/
|
||||||
private function loadPluginFiles($directory = '') {
|
private function loadPluginFiles($directory = '') {
|
||||||
$pluginFiles = scandir($directory);
|
$pluginFiles = scandir($directory);
|
||||||
foreach ($pluginFiles as $pluginFile) {
|
foreach($pluginFiles as $pluginFile) {
|
||||||
if (stripos($pluginFile, '.') === 0) {
|
if (stripos($pluginFile, '.') === 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -339,4 +343,23 @@ class PluginManager {
|
|||||||
$pluginStatement->close();
|
$pluginStatement->close();
|
||||||
return $active;
|
return $active;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch the plugin list of the ManiaControl Website
|
||||||
|
*
|
||||||
|
* @param $function
|
||||||
|
* @param bool $ignoreVersion
|
||||||
|
*/
|
||||||
|
private function fetchPluginList($function) {
|
||||||
|
$url = ManiaControl::URL_WEBSERVICE . 'plugins';
|
||||||
|
|
||||||
|
$this->maniaControl->fileReader->loadFile($url, function ($dataJson, $error) use (&$function) {
|
||||||
|
$data = json_decode($dataJson);
|
||||||
|
if (!$data || !isset($data[0])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
call_user_func($function, $data[0]);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user