fixed private property access in closure

This commit is contained in:
Steffen Schröder 2014-05-03 23:03:07 +02:00
parent 43a1cd99b0
commit f9b6437970

View File

@ -72,25 +72,23 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
$this->maniaControl->log($message);
$self = $this;
$this->maniaControl->pluginManager->fetchPluginList(function ($data, $error) use (&$self, &$player) {
$maniaControl = $this->maniaControl;
$this->maniaControl->pluginManager->fetchPluginList(function ($data, $error) use (&$self, &$maniaControl, &$player) {
if (!$data || $error) {
$message = 'Error while checking Plugins for newer Versions!';
if ($player) {
$self->maniaControl->chat->sendError($message, $player);
$maniaControl->chat->sendError($message, $player);
}
$self->maniaControl->log($message);
$maniaControl->log($message);
return;
}
$pluginsData = $self->parsePluginsData($data);
$pluginClasses = $self->maniaControl->pluginManager->getPluginClasses();
$pluginClasses = $maniaControl->pluginManager->getPluginClasses();
$pluginUpdates = array();
foreach ($pluginClasses as $pluginClass) {
/**
* @var Plugin $pluginClass
*/
/** @var Plugin $pluginClass */
$pluginId = $pluginClass::getId();
if (!isset($pluginsData[$pluginId])) {
continue;
@ -102,25 +100,25 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
$pluginUpdates[$pluginId] = $pluginData;
$message = "There is an Update of '{$pluginData->pluginName}' available! ('{$pluginClass}' - Version {$pluginData->version})";
if ($player) {
$self->maniaControl->chat->sendSuccess($message, $player);
$maniaControl->chat->sendSuccess($message, $player);
}
$self->maniaControl->log($message);
$maniaControl->log($message);
}
}
if (empty($pluginUpdates)) {
$message = 'Plugins Update Check completed: All Plugins are up-to-date!';
if ($player) {
$self->maniaControl->chat->sendSuccess($message, $player);
$maniaControl->chat->sendSuccess($message, $player);
}
$self->maniaControl->log($message);
$maniaControl->log($message);
} else {
$updatesCount = count($pluginUpdates);
$message = "Plugins Update Check completed: There are {$updatesCount} Updates available!";
if ($player) {
$self->maniaControl->chat->sendSuccess($message, $player);
$maniaControl->chat->sendSuccess($message, $player);
}
$self->maniaControl->log($message);
$maniaControl->log($message);
}
});
}