improved code
return loaded plugin classes
This commit is contained in:
parent
08d52f1a18
commit
17bbc89bc1
@ -93,7 +93,7 @@ class PluginManager {
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function isPluginClass($pluginClass) {
|
public static function isPluginClass($pluginClass) {
|
||||||
$pluginClass = self::getPluginClass($pluginClass);
|
$pluginClass = self::getClass($pluginClass);
|
||||||
if (!class_exists($pluginClass, false)) {
|
if (!class_exists($pluginClass, false)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -198,6 +198,8 @@ class PluginManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Load complete Plugins Directory and start all configured Plugins
|
* Load complete Plugins Directory and start all configured Plugins
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function loadPlugins() {
|
public function loadPlugins() {
|
||||||
$pluginsDirectory = ManiaControlDir . '/plugins/';
|
$pluginsDirectory = ManiaControlDir . '/plugins/';
|
||||||
@ -206,24 +208,27 @@ class PluginManager {
|
|||||||
$this->loadPluginFiles($pluginsDirectory);
|
$this->loadPluginFiles($pluginsDirectory);
|
||||||
$classesAfter = get_declared_classes();
|
$classesAfter = get_declared_classes();
|
||||||
|
|
||||||
|
$newPluginClasses = array();
|
||||||
|
|
||||||
$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);
|
if (!$this->addPluginClass($className)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
array_push($newPluginClasses, $className);
|
||||||
|
|
||||||
$className::prepare($this->maniaControl);
|
$className::prepare($this->maniaControl);
|
||||||
|
|
||||||
if ($this->isPluginActive($className)) {
|
if ($this->getSavedPluginStatus($className)) {
|
||||||
continue;
|
$this->activatePlugin($className);
|
||||||
}
|
}
|
||||||
if (!$this->getSavedPluginStatus($className)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->activatePlugin($className);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $newPluginClasses;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -360,10 +365,9 @@ class PluginManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch the plugin list of the ManiaControl Website
|
* Fetch the Plugins List from the ManiaControl Website
|
||||||
*
|
*
|
||||||
* @param $function
|
* @param $function
|
||||||
* @param bool $ignoreVersion
|
|
||||||
*/
|
*/
|
||||||
public function fetchPluginList($function) {
|
public function fetchPluginList($function) {
|
||||||
$url = ManiaControl::URL_WEBSERVICE . 'plugins';
|
$url = ManiaControl::URL_WEBSERVICE . 'plugins';
|
||||||
@ -381,9 +385,23 @@ class PluginManager {
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function getPluginClass($pluginClass) {
|
public static function getPluginClass($pluginClass) {
|
||||||
if (is_object($pluginClass)) {
|
$pluginClass = self::getClass($pluginClass);
|
||||||
$pluginClass = get_class($pluginClass);
|
if (!self::isPluginClass($pluginClass)) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return (string) $pluginClass;
|
return $pluginClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Class of the Object
|
||||||
|
*
|
||||||
|
* @param mixed $pluginClass
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private static function getClass($object) {
|
||||||
|
if (is_object($object)) {
|
||||||
|
return get_class($object);
|
||||||
|
}
|
||||||
|
return (string) $object;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user