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

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