mirror of
https://github.com/chylex/Nextcloud-News.git
synced 2025-05-13 19:34:05 +02:00
67 lines
1.5 KiB
PHP
67 lines
1.5 KiB
PHP
<?php
|
|
/**
|
|
* Nextcloud - News
|
|
*
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
* later. See the COPYING file.
|
|
*
|
|
* @author Sean Molenaar
|
|
* @copyright Sean Molenaar <sean@seanmolenaar.eu> 2020
|
|
*/
|
|
|
|
namespace OCA\News\Migration;
|
|
|
|
use OCA\News\AppInfo\Application;
|
|
use OCA\News\Config\LegacyConfig;
|
|
use OCP\IConfig;
|
|
use OCP\Migration\IRepairStep;
|
|
use OCP\Migration\IOutput;
|
|
|
|
class MigrateConfig implements IRepairStep
|
|
{
|
|
|
|
/**
|
|
* @var LegacyConfig
|
|
*/
|
|
private $config;
|
|
|
|
/**
|
|
* @var IConfig
|
|
*/
|
|
private $iConfig;
|
|
|
|
/**
|
|
* @param LegacyConfig $config
|
|
* @param IConfig $iConfig
|
|
*/
|
|
public function __construct(LegacyConfig $config, IConfig $iConfig)
|
|
{
|
|
$this->config = $config;
|
|
$this->iConfig = $iConfig;
|
|
}
|
|
|
|
public function getName()
|
|
{
|
|
return 'Migrate config to nextcloud managed config';
|
|
}
|
|
|
|
public function run(IOutput $output)
|
|
{
|
|
$version = $this->iConfig->getAppValue('news', 'installed_version', '0.0.0');
|
|
if (version_compare($version, '15.0.0', '>')) {
|
|
return;
|
|
}
|
|
|
|
$app_keys = $this->iConfig->getAppKeys(Application::NAME);
|
|
foreach ($this->config as $key => $value) {
|
|
if (!isset(Application::DEFAULT_SETTINGS[$key])) {
|
|
continue;
|
|
}
|
|
if (in_array($key, $app_keys)) {
|
|
continue;
|
|
}
|
|
$this->iConfig->setAppValue(Application::NAME, $key, $value);
|
|
}
|
|
}
|
|
}
|