Completed
Pull Request — stable9 (#227)
by Morris
11:06 queued 01:40
created

MoveChannelToSystemConfig   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 20
rs 10
wmc 4
lcom 1
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getName() 0 3 1
A run() 0 7 2
1
<?php
2
/**
3
 * @copyright Copyright (c) 2016 Lukas Reschke <[email protected]>
4
 *
5
 * @license GNU AGPL version 3 or any later version
6
 *
7
 * This program is free software: you can redistribute it and/or modify
8
 * it under the terms of the GNU Affero General Public License as
9
 * published by the Free Software Foundation, either version 3 of the
10
 * License, or (at your option) any later version.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 * GNU Affero General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Affero General Public License
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 *
20
 */
21
namespace OC\Repair;
22
23
use OC\Hooks\BasicEmitter;
24
use OCP\IConfig;
25
26
/**
27
 * Class MoveChannelToSystemConfig moves the defined OC_Channel in the app config
28
 * to the system config to be compatible with the Nextcloud updater.
29
 *
30
 * @package OC\Repair
31
 */
32
class MoveChannelToSystemConfig extends BasicEmitter implements \OC\RepairStep {
33
	/** @var IConfig */
34
	private $config;
35
36
	public function __construct(IConfig $config) {
37
		$this->config = $config;
38
	}
39
40
	public function getName() {
41
		return 'Moves the stored release channel to the config file';
42
	}
43
44
	public function run() {
45
		$channel = $this->config->getAppValue('core', 'OC_Channel', '');
46
		if($channel !== '') {
47
			$this->config->setSystemValue('updater.release.channel', $channel);
48
			$this->config->deleteAppValue('core', 'OC_Channel');
49
		}
50
	}
51
}
52