StartCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 45
ccs 0
cts 17
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 6 1
A execute() 0 12 3
1
<?php
2
/**
3
 * @author Victor Dubiniuk <[email protected]>
4
 *
5
 * @copyright Copyright (c) 2015, ownCloud, Inc.
6
 * @license AGPL-3.0
7
 *
8
 * This code is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU Affero General Public License, version 3,
10
 * as published by the Free Software Foundation.
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, version 3,
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
19
 *
20
 */
21
22
namespace Owncloud\Updater\Command;
23
24
use Symfony\Component\Console\Input\InputInterface;
25
use Symfony\Component\Console\Output\OutputInterface;
26
use Symfony\Component\Console\Input\ArrayInput;
27
28
/**
29
 * Class StartCommand
30
 *
31
 * @package Owncloud\Updater\Command
32
 */
33
class StartCommand extends Command {
34
35
	protected $stack = [
36
		[ 'command' => 'upgrade:info'],
37
		[ 'command' => 'upgrade:checkSystem'],
38
		[ 'command' => 'upgrade:detect', '--exit-if-none' => '1'],
39
		//[ 'command' => 'upgrade:maintenanceMode', '--on' => '1'],
40
		[ 'command' => 'upgrade:backupDb'],
41
		[ 'command' => 'upgrade:backupData'],
42
		[ 'command' => 'upgrade:checkpoint', '--create' => '1'],
43
		[ 'command' => 'upgrade:preUpgradeRepair'],
44
		[ 'command' => 'upgrade:executeCoreUpgradeScripts'],
45
		[ 'command' => 'upgrade:cleanCache'],
46
		[ 'command' => 'upgrade:postUpgradeRepair'],
47
		[ 'command' => 'upgrade:restartWebServer'],
48
		[ 'command' => 'upgrade:updateConfig'],
49
		//[ 'command' => 'upgrade:maintenanceMode', '--off' => '1'],
50
		[ 'command' => 'upgrade:postUpgradeCleanup'],
51
	];
52
53
	protected function configure(){
54
		$this
55
				->setName('upgrade:start')
56
				->setDescription('automated process')
57
		;
58
	}
59
60
	/**
61
	 * @param InputInterface $input
62
	 * @param OutputInterface $output
63
	 */
64
	protected function execute(InputInterface $input, OutputInterface $output){
65
		$app = $this->getApplication();
66
		foreach ($this->stack as $command){
67
			$input = new ArrayInput($command);
68
			$returnCode = $app->doRun($input, $output);
69
			if ($returnCode != 0){
70
				// Something went wrong
71
				break;
72
			}
73
		}
74
		$output->writeln('Done');
75
	}
76
77
}
78