Completed
Push — master ( 2493d7...51beeb )
by Maxence
03:12 queued 12s
created

Migration::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
6
/**
7
 * Circles - Bring cloud-users closer together.
8
 *
9
 * This file is licensed under the Affero General Public License version 3 or
10
 * later. See the COPYING file.
11
 *
12
 * @author Maxence Lange <[email protected]>
13
 * @copyright 2021
14
 * @license GNU AGPL version 3 or any later version
15
 *
16
 * This program is free software: you can redistribute it and/or modify
17
 * it under the terms of the GNU Affero General Public License as
18
 * published by the Free Software Foundation, either version 3 of the
19
 * License, or (at your option) any later version.
20
 *
21
 * This program is distributed in the hope that it will be useful,
22
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
 * GNU Affero General Public License for more details.
25
 *
26
 * You should have received a copy of the GNU Affero General Public License
27
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
28
 *
29
 */
30
31
32
namespace OCA\Circles\Migration;
33
34
35
use ArtificialOwl\MySmallPhpTools\Traits\Nextcloud\nc22\TNC22Logger;
36
use Exception;
37
use OCA\Circles\AppInfo\Application;
38
use OCA\Circles\Service\ConfigService;
39
use OCA\Circles\Service\MigrationService;
40
use OCA\Circles\Service\OutputService;
41
use OCP\Migration\IOutput;
42
use OCP\Migration\IRepairStep;
43
44
45
/**
46
 * Class Migration
47
 *
48
 * @package OCA\Circles\Migration
49
 */
50
class Migration implements IRepairStep {
51
52
53
	use TNC22Logger;
54
55
56
	/** @var MigrationService */
57
	private $migrationService;
58
59
	private $outputService;
60
61
	/** @var ConfigService */
62
	private $configService;
63
64
65
	/**
66
	 * Migration constructor.
67
	 *
68
	 * @param MigrationService $migrationService
69
	 * @param OutputService $outputService
70
	 * @param ConfigService $configService
71
	 */
72
	public function __construct(
73
		MigrationService $migrationService,
74
		OutputService $outputService,
75
		ConfigService $configService
76
	) {
77
		$this->migrationService = $migrationService;
78
		$this->outputService = $outputService;
79
		$this->configService = $configService;
80
	}
81
82
83
	/**
84
	 * @return string
85
	 */
86
	public function getName(): string {
87
		return 'Upgrading Circles App';
88
	}
89
90
91
	/**
92
	 * @param IOutput $output
93
	 */
94
	public function run(IOutput $output) {
95
		if ($this->configService->getAppValueBool(ConfigService::MIGRATION_BYPASS)) {
96
			return;
97
		}
98
99
		$this->outputService->setMigrationOutput($output);
100
101
		try {
102
			$this->migrationService->migration();
103
		} catch (Exception $e) {
104
			$this->e($e);
105
		}
106
	}
107
108
}
109
110