setName('plugin:upgrade')
->setDescription('Update all installed plugins')
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
if (!Installer::isConfigured()) {
$output->writeln('Kanboard is not configured to upgrade plugins itself');
}
$installer = new Installer($this->container);
$availablePlugins = Directory::getInstance($this->container)->getAvailablePlugins();
foreach ($this->pluginLoader->getPlugins() as $installedPlugin) {
$pluginDetails = $this->getPluginDetails($availablePlugins, $installedPlugin);
if ($pluginDetails === null) {
$output->writeln('* Plugin not available in the directory: '.$installedPlugin->getPluginName().'');
} elseif ($pluginDetails['version'] > $installedPlugin->getPluginVersion()) {
$output->writeln('* Updating plugin: '.$installedPlugin->getPluginName().'');
$installer->update($pluginDetails['download']);
} else {
$output->writeln('* Plugin up to date: '.$installedPlugin->getPluginName().'');
}
}
}
protected function getPluginDetails(array $availablePlugins, BasePlugin $installedPlugin)
{
foreach ($availablePlugins as $availablePlugin) {
if ($availablePlugin['title'] === $installedPlugin->getPluginName()) {
return $availablePlugin;
}
}
return null;
}
}