refactor codestyle (chaining)
This commit is contained in:
@ -50,12 +50,10 @@ class PluginManager {
|
||||
$this->initTables();
|
||||
|
||||
$this->pluginMenu = new PluginMenu($maniaControl);
|
||||
$this->maniaControl->getConfigurator()
|
||||
->addMenu($this->pluginMenu);
|
||||
$this->maniaControl->getConfigurator()->addMenu($this->pluginMenu);
|
||||
|
||||
$this->pluginInstallMenu = new InstallMenu($maniaControl);
|
||||
$this->maniaControl->getConfigurator()
|
||||
->addMenu($this->pluginInstallMenu);
|
||||
$this->maniaControl->getConfigurator()->addMenu($this->pluginInstallMenu);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -64,8 +62,7 @@ class PluginManager {
|
||||
* @return bool
|
||||
*/
|
||||
private function initTables() {
|
||||
$mysqli = $this->maniaControl->getDatabase()
|
||||
->getMysqli();
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$pluginsTableQuery = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_PLUGINS . "` (
|
||||
`index` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`className` varchar(100) NOT NULL,
|
||||
@ -145,28 +142,22 @@ class PluginManager {
|
||||
$plugin->unload();
|
||||
|
||||
if ($plugin instanceof CallbackListener) {
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->unregisterCallbackListener($plugin);
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->unregisterScriptCallbackListener($plugin);
|
||||
$this->maniaControl->getCallbackManager()->unregisterCallbackListener($plugin);
|
||||
$this->maniaControl->getCallbackManager()->unregisterScriptCallbackListener($plugin);
|
||||
}
|
||||
if ($plugin instanceof CommandListener) {
|
||||
$this->maniaControl->getCommandManager()
|
||||
->unregisterCommandListener($plugin);
|
||||
$this->maniaControl->getCommandManager()->unregisterCommandListener($plugin);
|
||||
}
|
||||
if ($plugin instanceof ManialinkPageAnswerListener) {
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->unregisterManialinkPageAnswerListener($plugin);
|
||||
$this->maniaControl->getManialinkManager()->unregisterManialinkPageAnswerListener($plugin);
|
||||
}
|
||||
if ($plugin instanceof TimerListener) {
|
||||
$this->maniaControl->getTimerManager()
|
||||
->unregisterTimerListenings($plugin);
|
||||
$this->maniaControl->getTimerManager()->unregisterTimerListenings($plugin);
|
||||
}
|
||||
|
||||
$this->savePluginStatus($pluginClass, false);
|
||||
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(self::CB_PLUGIN_UNLOADED, $pluginClass, $plugin);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_PLUGIN_UNLOADED, $pluginClass, $plugin);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -204,8 +195,7 @@ class PluginManager {
|
||||
* @return bool
|
||||
*/
|
||||
private function savePluginStatus($className, $active) {
|
||||
$mysqli = $this->maniaControl->getDatabase()
|
||||
->getMysqli();
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$pluginStatusQuery = "INSERT INTO `" . self::TABLE_PLUGINS . "` (
|
||||
`className`,
|
||||
`active`
|
||||
@ -349,8 +339,7 @@ class PluginManager {
|
||||
* @return bool
|
||||
*/
|
||||
public function getSavedPluginStatus($className) {
|
||||
$mysqli = $this->maniaControl->getDatabase()
|
||||
->getMysqli();
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$pluginStatusQuery = "SELECT `active` FROM `" . self::TABLE_PLUGINS . "`
|
||||
WHERE `className` = ?;";
|
||||
$pluginStatement = $mysqli->prepare($pluginStatusQuery);
|
||||
@ -401,8 +390,7 @@ class PluginManager {
|
||||
$plugin->load($this->maniaControl);
|
||||
} catch (\Exception $e) {
|
||||
$message = "Error during Plugin Activation of '{$pluginClass}': '{$e->getMessage()}'";
|
||||
$this->maniaControl->getChat()
|
||||
->sendError($message, $adminLogin);
|
||||
$this->maniaControl->getChat()->sendError($message, $adminLogin);
|
||||
Logger::logError($message);
|
||||
$this->savePluginStatus($pluginClass, false);
|
||||
return false;
|
||||
@ -411,8 +399,7 @@ class PluginManager {
|
||||
$this->activePlugins[$pluginClass] = $plugin;
|
||||
$this->savePluginStatus($pluginClass, true);
|
||||
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(self::CB_PLUGIN_LOADED, $pluginClass, $plugin);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_PLUGIN_LOADED, $pluginClass, $plugin);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -487,10 +474,9 @@ class PluginManager {
|
||||
*/
|
||||
public function fetchPluginList(callable $function) {
|
||||
$url = ManiaControl::URL_WEBSERVICE . 'plugins';
|
||||
$this->maniaControl->getFileReader()
|
||||
->loadFile($url, function ($dataJson, $error) use (&$function) {
|
||||
$data = json_decode($dataJson);
|
||||
call_user_func($function, $data, $error);
|
||||
});
|
||||
$this->maniaControl->getFileReader()->loadFile($url, function ($dataJson, $error) use (&$function) {
|
||||
$data = json_decode($dataJson);
|
||||
call_user_func($function, $data, $error);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user