summaryrefslogtreecommitdiffstats
path: root/lib/Migration
diff options
context:
space:
mode:
authorSean Molenaar <sean@seanmolenaar.eu>2020-09-20 22:03:05 +0200
committerBenjamin Brahmer <info@b-brahmer.de>2020-09-25 19:18:04 +0200
commit60ab4941cc7e6ede095e9e4aee3c2bf9a5c3bff6 (patch)
treebaf0b07dd1c545efeb59437af46a99f4d9f69425 /lib/Migration
parent2c8b4fa019749113658b9ed8cae211b679e4cbc0 (diff)
Move to nextcloud config and update phpunit
Signed-off-by: Sean Molenaar <sean@seanmolenaar.eu>
Diffstat (limited to 'lib/Migration')
-rw-r--r--lib/Migration/MigrateConfig.php59
1 files changed, 59 insertions, 0 deletions
diff --git a/lib/Migration/MigrateConfig.php b/lib/Migration/MigrateConfig.php
new file mode 100644
index 000000000..b25fb8e75
--- /dev/null
+++ b/lib/Migration/MigrateConfig.php
@@ -0,0 +1,59 @@
+<?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;
+ }
+
+ foreach ($this->config as $key => $value) {
+ $this->iConfig->setAppValue(Application::NAME, $key, $value);
+ }
+ }
+}