Passed
Push — master ( ebedbf...47a21f )
by Joas
12:46 queued 18s
created
core/Command/Config/System/SetConfig.php 1 patch
Indentation   +177 added lines, -177 removed lines patch added patch discarded remove patch
@@ -33,181 +33,181 @@
 block discarded – undo
33 33
 use Symfony\Component\Console\Output\OutputInterface;
34 34
 
35 35
 class SetConfig extends Base {
36
-	/** * @var SystemConfig */
37
-	protected $systemConfig;
38
-
39
-	/**
40
-	 * @param SystemConfig $systemConfig
41
-	 */
42
-	public function __construct(SystemConfig $systemConfig) {
43
-		parent::__construct();
44
-		$this->systemConfig = $systemConfig;
45
-	}
46
-
47
-	protected function configure() {
48
-		parent::configure();
49
-
50
-		$this
51
-			->setName('config:system:set')
52
-			->setDescription('Set a system config value')
53
-			->addArgument(
54
-				'name',
55
-				InputArgument::REQUIRED | InputArgument::IS_ARRAY,
56
-				'Name of the config parameter, specify multiple for array parameter'
57
-			)
58
-			->addOption(
59
-				'type',
60
-				null,
61
-				InputOption::VALUE_REQUIRED,
62
-				'Value type [string, integer, double, boolean]',
63
-				'string'
64
-			)
65
-			->addOption(
66
-				'value',
67
-				null,
68
-				InputOption::VALUE_REQUIRED,
69
-				'The new value of the config'
70
-			)
71
-			->addOption(
72
-				'update-only',
73
-				null,
74
-				InputOption::VALUE_NONE,
75
-				'Only updates the value, if it is not set before, it is not being added'
76
-			)
77
-		;
78
-	}
79
-
80
-	protected function execute(InputInterface $input, OutputInterface $output): int {
81
-		$configNames = $input->getArgument('name');
82
-		$configName = $configNames[0];
83
-		$configValue = $this->castValue($input->getOption('value'), $input->getOption('type'));
84
-		$updateOnly = $input->getOption('update-only');
85
-
86
-		if (count($configNames) > 1) {
87
-			$existingValue = $this->systemConfig->getValue($configName);
88
-
89
-			$newValue = $this->mergeArrayValue(
90
-				array_slice($configNames, 1), $existingValue, $configValue['value'], $updateOnly
91
-			);
92
-
93
-			$this->systemConfig->setValue($configName, $newValue);
94
-		} else {
95
-			if ($updateOnly && !in_array($configName, $this->systemConfig->getKeys(), true)) {
96
-				throw new \UnexpectedValueException('Config parameter does not exist');
97
-			}
98
-
99
-			$this->systemConfig->setValue($configName, $configValue['value']);
100
-		}
101
-
102
-		$output->writeln('<info>System config value ' . implode(' => ', $configNames) . ' set to ' . $configValue['readable-value'] . '</info>');
103
-		return 0;
104
-	}
105
-
106
-	/**
107
-	 * @param string $value
108
-	 * @param string $type
109
-	 * @return mixed
110
-	 * @throws \InvalidArgumentException
111
-	 */
112
-	protected function castValue($value, $type) {
113
-		switch ($type) {
114
-			case 'integer':
115
-			case 'int':
116
-				if (!is_numeric($value)) {
117
-					throw new \InvalidArgumentException('Non-numeric value specified');
118
-				}
119
-				return [
120
-					'value' => (int) $value,
121
-					'readable-value' => 'integer ' . (int) $value,
122
-				];
123
-
124
-			case 'double':
125
-			case 'float':
126
-				if (!is_numeric($value)) {
127
-					throw new \InvalidArgumentException('Non-numeric value specified');
128
-				}
129
-				return [
130
-					'value' => (double) $value,
131
-					'readable-value' => 'double ' . (double) $value,
132
-				];
133
-
134
-			case 'boolean':
135
-			case 'bool':
136
-				$value = strtolower($value);
137
-				switch ($value) {
138
-					case 'true':
139
-						return [
140
-							'value' => true,
141
-							'readable-value' => 'boolean ' . $value,
142
-						];
143
-
144
-					case 'false':
145
-						return [
146
-							'value' => false,
147
-							'readable-value' => 'boolean ' . $value,
148
-						];
149
-
150
-					default:
151
-						throw new \InvalidArgumentException('Unable to parse value as boolean');
152
-				}
153
-
154
-				// no break
155
-			case 'null':
156
-				return [
157
-					'value' => null,
158
-					'readable-value' => 'null',
159
-				];
160
-
161
-			case 'string':
162
-				$value = (string) $value;
163
-				return [
164
-					'value' => $value,
165
-					'readable-value' => ($value === '') ? 'empty string' : 'string ' . $value,
166
-				];
167
-
168
-			default:
169
-				throw new \InvalidArgumentException('Invalid type');
170
-		}
171
-	}
172
-
173
-	/**
174
-	 * @param array $configNames
175
-	 * @param mixed $existingValues
176
-	 * @param mixed $value
177
-	 * @param bool $updateOnly
178
-	 * @return array merged value
179
-	 * @throws \UnexpectedValueException
180
-	 */
181
-	protected function mergeArrayValue(array $configNames, $existingValues, $value, $updateOnly) {
182
-		$configName = array_shift($configNames);
183
-		if (!is_array($existingValues)) {
184
-			$existingValues = [];
185
-		}
186
-		if (!empty($configNames)) {
187
-			if (isset($existingValues[$configName])) {
188
-				$existingValue = $existingValues[$configName];
189
-			} else {
190
-				$existingValue = [];
191
-			}
192
-			$existingValues[$configName] = $this->mergeArrayValue($configNames, $existingValue, $value, $updateOnly);
193
-		} else {
194
-			if (!isset($existingValues[$configName]) && $updateOnly) {
195
-				throw new \UnexpectedValueException('Config parameter does not exist');
196
-			}
197
-			$existingValues[$configName] = $value;
198
-		}
199
-		return $existingValues;
200
-	}
201
-
202
-	/**
203
-	 * @param string $optionName
204
-	 * @param CompletionContext $context
205
-	 * @return string[]
206
-	 */
207
-	public function completeOptionValues($optionName, CompletionContext $context) {
208
-		if ($optionName === 'type') {
209
-			return ['string', 'integer', 'double', 'boolean'];
210
-		}
211
-		return parent::completeOptionValues($optionName, $context);
212
-	}
36
+    /** * @var SystemConfig */
37
+    protected $systemConfig;
38
+
39
+    /**
40
+     * @param SystemConfig $systemConfig
41
+     */
42
+    public function __construct(SystemConfig $systemConfig) {
43
+        parent::__construct();
44
+        $this->systemConfig = $systemConfig;
45
+    }
46
+
47
+    protected function configure() {
48
+        parent::configure();
49
+
50
+        $this
51
+            ->setName('config:system:set')
52
+            ->setDescription('Set a system config value')
53
+            ->addArgument(
54
+                'name',
55
+                InputArgument::REQUIRED | InputArgument::IS_ARRAY,
56
+                'Name of the config parameter, specify multiple for array parameter'
57
+            )
58
+            ->addOption(
59
+                'type',
60
+                null,
61
+                InputOption::VALUE_REQUIRED,
62
+                'Value type [string, integer, double, boolean]',
63
+                'string'
64
+            )
65
+            ->addOption(
66
+                'value',
67
+                null,
68
+                InputOption::VALUE_REQUIRED,
69
+                'The new value of the config'
70
+            )
71
+            ->addOption(
72
+                'update-only',
73
+                null,
74
+                InputOption::VALUE_NONE,
75
+                'Only updates the value, if it is not set before, it is not being added'
76
+            )
77
+        ;
78
+    }
79
+
80
+    protected function execute(InputInterface $input, OutputInterface $output): int {
81
+        $configNames = $input->getArgument('name');
82
+        $configName = $configNames[0];
83
+        $configValue = $this->castValue($input->getOption('value'), $input->getOption('type'));
84
+        $updateOnly = $input->getOption('update-only');
85
+
86
+        if (count($configNames) > 1) {
87
+            $existingValue = $this->systemConfig->getValue($configName);
88
+
89
+            $newValue = $this->mergeArrayValue(
90
+                array_slice($configNames, 1), $existingValue, $configValue['value'], $updateOnly
91
+            );
92
+
93
+            $this->systemConfig->setValue($configName, $newValue);
94
+        } else {
95
+            if ($updateOnly && !in_array($configName, $this->systemConfig->getKeys(), true)) {
96
+                throw new \UnexpectedValueException('Config parameter does not exist');
97
+            }
98
+
99
+            $this->systemConfig->setValue($configName, $configValue['value']);
100
+        }
101
+
102
+        $output->writeln('<info>System config value ' . implode(' => ', $configNames) . ' set to ' . $configValue['readable-value'] . '</info>');
103
+        return 0;
104
+    }
105
+
106
+    /**
107
+     * @param string $value
108
+     * @param string $type
109
+     * @return mixed
110
+     * @throws \InvalidArgumentException
111
+     */
112
+    protected function castValue($value, $type) {
113
+        switch ($type) {
114
+            case 'integer':
115
+            case 'int':
116
+                if (!is_numeric($value)) {
117
+                    throw new \InvalidArgumentException('Non-numeric value specified');
118
+                }
119
+                return [
120
+                    'value' => (int) $value,
121
+                    'readable-value' => 'integer ' . (int) $value,
122
+                ];
123
+
124
+            case 'double':
125
+            case 'float':
126
+                if (!is_numeric($value)) {
127
+                    throw new \InvalidArgumentException('Non-numeric value specified');
128
+                }
129
+                return [
130
+                    'value' => (double) $value,
131
+                    'readable-value' => 'double ' . (double) $value,
132
+                ];
133
+
134
+            case 'boolean':
135
+            case 'bool':
136
+                $value = strtolower($value);
137
+                switch ($value) {
138
+                    case 'true':
139
+                        return [
140
+                            'value' => true,
141
+                            'readable-value' => 'boolean ' . $value,
142
+                        ];
143
+
144
+                    case 'false':
145
+                        return [
146
+                            'value' => false,
147
+                            'readable-value' => 'boolean ' . $value,
148
+                        ];
149
+
150
+                    default:
151
+                        throw new \InvalidArgumentException('Unable to parse value as boolean');
152
+                }
153
+
154
+                // no break
155
+            case 'null':
156
+                return [
157
+                    'value' => null,
158
+                    'readable-value' => 'null',
159
+                ];
160
+
161
+            case 'string':
162
+                $value = (string) $value;
163
+                return [
164
+                    'value' => $value,
165
+                    'readable-value' => ($value === '') ? 'empty string' : 'string ' . $value,
166
+                ];
167
+
168
+            default:
169
+                throw new \InvalidArgumentException('Invalid type');
170
+        }
171
+    }
172
+
173
+    /**
174
+     * @param array $configNames
175
+     * @param mixed $existingValues
176
+     * @param mixed $value
177
+     * @param bool $updateOnly
178
+     * @return array merged value
179
+     * @throws \UnexpectedValueException
180
+     */
181
+    protected function mergeArrayValue(array $configNames, $existingValues, $value, $updateOnly) {
182
+        $configName = array_shift($configNames);
183
+        if (!is_array($existingValues)) {
184
+            $existingValues = [];
185
+        }
186
+        if (!empty($configNames)) {
187
+            if (isset($existingValues[$configName])) {
188
+                $existingValue = $existingValues[$configName];
189
+            } else {
190
+                $existingValue = [];
191
+            }
192
+            $existingValues[$configName] = $this->mergeArrayValue($configNames, $existingValue, $value, $updateOnly);
193
+        } else {
194
+            if (!isset($existingValues[$configName]) && $updateOnly) {
195
+                throw new \UnexpectedValueException('Config parameter does not exist');
196
+            }
197
+            $existingValues[$configName] = $value;
198
+        }
199
+        return $existingValues;
200
+    }
201
+
202
+    /**
203
+     * @param string $optionName
204
+     * @param CompletionContext $context
205
+     * @return string[]
206
+     */
207
+    public function completeOptionValues($optionName, CompletionContext $context) {
208
+        if ($optionName === 'type') {
209
+            return ['string', 'integer', 'double', 'boolean'];
210
+        }
211
+        return parent::completeOptionValues($optionName, $context);
212
+    }
213 213
 }
Please login to merge, or discard this patch.
core/Command/Config/System/GetConfig.php 1 patch
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -30,72 +30,72 @@
 block discarded – undo
30 30
 use Symfony\Component\Console\Output\OutputInterface;
31 31
 
32 32
 class GetConfig extends Base {
33
-	/** * @var SystemConfig */
34
-	protected $systemConfig;
33
+    /** * @var SystemConfig */
34
+    protected $systemConfig;
35 35
 
36
-	/**
37
-	 * @param SystemConfig $systemConfig
38
-	 */
39
-	public function __construct(SystemConfig $systemConfig) {
40
-		parent::__construct();
41
-		$this->systemConfig = $systemConfig;
42
-	}
36
+    /**
37
+     * @param SystemConfig $systemConfig
38
+     */
39
+    public function __construct(SystemConfig $systemConfig) {
40
+        parent::__construct();
41
+        $this->systemConfig = $systemConfig;
42
+    }
43 43
 
44
-	protected function configure() {
45
-		parent::configure();
44
+    protected function configure() {
45
+        parent::configure();
46 46
 
47
-		$this
48
-			->setName('config:system:get')
49
-			->setDescription('Get a system config value')
50
-			->addArgument(
51
-				'name',
52
-				InputArgument::REQUIRED | InputArgument::IS_ARRAY,
53
-				'Name of the config to get, specify multiple for array parameter'
54
-			)
55
-			->addOption(
56
-				'default-value',
57
-				null,
58
-				InputOption::VALUE_OPTIONAL,
59
-				'If no default value is set and the config does not exist, the command will exit with 1'
60
-			)
61
-		;
62
-	}
47
+        $this
48
+            ->setName('config:system:get')
49
+            ->setDescription('Get a system config value')
50
+            ->addArgument(
51
+                'name',
52
+                InputArgument::REQUIRED | InputArgument::IS_ARRAY,
53
+                'Name of the config to get, specify multiple for array parameter'
54
+            )
55
+            ->addOption(
56
+                'default-value',
57
+                null,
58
+                InputOption::VALUE_OPTIONAL,
59
+                'If no default value is set and the config does not exist, the command will exit with 1'
60
+            )
61
+        ;
62
+    }
63 63
 
64
-	/**
65
-	 * Executes the current command.
66
-	 *
67
-	 * @param InputInterface  $input  An InputInterface instance
68
-	 * @param OutputInterface $output An OutputInterface instance
69
-	 * @return null|int null or 0 if everything went fine, or an error code
70
-	 */
71
-	protected function execute(InputInterface $input, OutputInterface $output): int {
72
-		$configNames = $input->getArgument('name');
73
-		$configName = array_shift($configNames);
74
-		$defaultValue = $input->getOption('default-value');
64
+    /**
65
+     * Executes the current command.
66
+     *
67
+     * @param InputInterface  $input  An InputInterface instance
68
+     * @param OutputInterface $output An OutputInterface instance
69
+     * @return null|int null or 0 if everything went fine, or an error code
70
+     */
71
+    protected function execute(InputInterface $input, OutputInterface $output): int {
72
+        $configNames = $input->getArgument('name');
73
+        $configName = array_shift($configNames);
74
+        $defaultValue = $input->getOption('default-value');
75 75
 
76
-		if (!in_array($configName, $this->systemConfig->getKeys()) && !$input->hasParameterOption('--default-value')) {
77
-			return 1;
78
-		}
76
+        if (!in_array($configName, $this->systemConfig->getKeys()) && !$input->hasParameterOption('--default-value')) {
77
+            return 1;
78
+        }
79 79
 
80
-		if (!in_array($configName, $this->systemConfig->getKeys())) {
81
-			$configValue = $defaultValue;
82
-		} else {
83
-			$configValue = $this->systemConfig->getValue($configName);
84
-			if (!empty($configNames)) {
85
-				foreach ($configNames as $configName) {
86
-					if (isset($configValue[$configName])) {
87
-						$configValue = $configValue[$configName];
88
-					} elseif (!$input->hasParameterOption('--default-value')) {
89
-						return 1;
90
-					} else {
91
-						$configValue = $defaultValue;
92
-						break;
93
-					}
94
-				}
95
-			}
96
-		}
80
+        if (!in_array($configName, $this->systemConfig->getKeys())) {
81
+            $configValue = $defaultValue;
82
+        } else {
83
+            $configValue = $this->systemConfig->getValue($configName);
84
+            if (!empty($configNames)) {
85
+                foreach ($configNames as $configName) {
86
+                    if (isset($configValue[$configName])) {
87
+                        $configValue = $configValue[$configName];
88
+                    } elseif (!$input->hasParameterOption('--default-value')) {
89
+                        return 1;
90
+                    } else {
91
+                        $configValue = $defaultValue;
92
+                        break;
93
+                    }
94
+                }
95
+            }
96
+        }
97 97
 
98
-		$this->writeMixedInOutputFormat($input, $output, $configValue);
99
-		return 0;
100
-	}
98
+        $this->writeMixedInOutputFormat($input, $output, $configValue);
99
+        return 0;
100
+    }
101 101
 }
Please login to merge, or discard this patch.
core/Command/Config/System/DeleteConfig.php 1 patch
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -31,88 +31,88 @@
 block discarded – undo
31 31
 use Symfony\Component\Console\Output\OutputInterface;
32 32
 
33 33
 class DeleteConfig extends Base {
34
-	/** * @var SystemConfig */
35
-	protected $systemConfig;
34
+    /** * @var SystemConfig */
35
+    protected $systemConfig;
36 36
 
37
-	/**
38
-	 * @param SystemConfig $systemConfig
39
-	 */
40
-	public function __construct(SystemConfig $systemConfig) {
41
-		parent::__construct();
42
-		$this->systemConfig = $systemConfig;
43
-	}
37
+    /**
38
+     * @param SystemConfig $systemConfig
39
+     */
40
+    public function __construct(SystemConfig $systemConfig) {
41
+        parent::__construct();
42
+        $this->systemConfig = $systemConfig;
43
+    }
44 44
 
45
-	protected function configure() {
46
-		parent::configure();
45
+    protected function configure() {
46
+        parent::configure();
47 47
 
48
-		$this
49
-			->setName('config:system:delete')
50
-			->setDescription('Delete a system config value')
51
-			->addArgument(
52
-				'name',
53
-				InputArgument::REQUIRED | InputArgument::IS_ARRAY,
54
-				'Name of the config to delete, specify multiple for array parameter'
55
-			)
56
-			->addOption(
57
-				'error-if-not-exists',
58
-				null,
59
-				InputOption::VALUE_NONE,
60
-				'Checks whether the config exists before deleting it'
61
-			)
62
-		;
63
-	}
48
+        $this
49
+            ->setName('config:system:delete')
50
+            ->setDescription('Delete a system config value')
51
+            ->addArgument(
52
+                'name',
53
+                InputArgument::REQUIRED | InputArgument::IS_ARRAY,
54
+                'Name of the config to delete, specify multiple for array parameter'
55
+            )
56
+            ->addOption(
57
+                'error-if-not-exists',
58
+                null,
59
+                InputOption::VALUE_NONE,
60
+                'Checks whether the config exists before deleting it'
61
+            )
62
+        ;
63
+    }
64 64
 
65
-	protected function execute(InputInterface $input, OutputInterface $output): int {
66
-		$configNames = $input->getArgument('name');
67
-		$configName = $configNames[0];
65
+    protected function execute(InputInterface $input, OutputInterface $output): int {
66
+        $configNames = $input->getArgument('name');
67
+        $configName = $configNames[0];
68 68
 
69
-		if (count($configNames) > 1) {
70
-			if ($input->hasParameterOption('--error-if-not-exists') && !in_array($configName, $this->systemConfig->getKeys())) {
71
-				$output->writeln('<error>System config ' . implode(' => ', $configNames) . ' could not be deleted because it did not exist</error>');
72
-				return 1;
73
-			}
69
+        if (count($configNames) > 1) {
70
+            if ($input->hasParameterOption('--error-if-not-exists') && !in_array($configName, $this->systemConfig->getKeys())) {
71
+                $output->writeln('<error>System config ' . implode(' => ', $configNames) . ' could not be deleted because it did not exist</error>');
72
+                return 1;
73
+            }
74 74
 
75
-			$value = $this->systemConfig->getValue($configName);
75
+            $value = $this->systemConfig->getValue($configName);
76 76
 
77
-			try {
78
-				$value = $this->removeSubValue(array_slice($configNames, 1), $value, $input->hasParameterOption('--error-if-not-exists'));
79
-			} catch (\UnexpectedValueException $e) {
80
-				$output->writeln('<error>System config ' . implode(' => ', $configNames) . ' could not be deleted because it did not exist</error>');
81
-				return 1;
82
-			}
77
+            try {
78
+                $value = $this->removeSubValue(array_slice($configNames, 1), $value, $input->hasParameterOption('--error-if-not-exists'));
79
+            } catch (\UnexpectedValueException $e) {
80
+                $output->writeln('<error>System config ' . implode(' => ', $configNames) . ' could not be deleted because it did not exist</error>');
81
+                return 1;
82
+            }
83 83
 
84
-			$this->systemConfig->setValue($configName, $value);
85
-			$output->writeln('<info>System config value ' . implode(' => ', $configNames) . ' deleted</info>');
86
-			return 0;
87
-		} else {
88
-			if ($input->hasParameterOption('--error-if-not-exists') && !in_array($configName, $this->systemConfig->getKeys())) {
89
-				$output->writeln('<error>System config ' . $configName . ' could not be deleted because it did not exist</error>');
90
-				return 1;
91
-			}
84
+            $this->systemConfig->setValue($configName, $value);
85
+            $output->writeln('<info>System config value ' . implode(' => ', $configNames) . ' deleted</info>');
86
+            return 0;
87
+        } else {
88
+            if ($input->hasParameterOption('--error-if-not-exists') && !in_array($configName, $this->systemConfig->getKeys())) {
89
+                $output->writeln('<error>System config ' . $configName . ' could not be deleted because it did not exist</error>');
90
+                return 1;
91
+            }
92 92
 
93
-			$this->systemConfig->deleteValue($configName);
94
-			$output->writeln('<info>System config value ' . $configName . ' deleted</info>');
95
-			return 0;
96
-		}
97
-	}
93
+            $this->systemConfig->deleteValue($configName);
94
+            $output->writeln('<info>System config value ' . $configName . ' deleted</info>');
95
+            return 0;
96
+        }
97
+    }
98 98
 
99
-	protected function removeSubValue($keys, $currentValue, $throwError) {
100
-		$nextKey = array_shift($keys);
99
+    protected function removeSubValue($keys, $currentValue, $throwError) {
100
+        $nextKey = array_shift($keys);
101 101
 
102
-		if (is_array($currentValue)) {
103
-			if (isset($currentValue[$nextKey])) {
104
-				if (empty($keys)) {
105
-					unset($currentValue[$nextKey]);
106
-				} else {
107
-					$currentValue[$nextKey] = $this->removeSubValue($keys, $currentValue[$nextKey], $throwError);
108
-				}
109
-			} elseif ($throwError) {
110
-				throw new \UnexpectedValueException('Config parameter does not exist');
111
-			}
112
-		} elseif ($throwError) {
113
-			throw new \UnexpectedValueException('Config parameter does not exist');
114
-		}
102
+        if (is_array($currentValue)) {
103
+            if (isset($currentValue[$nextKey])) {
104
+                if (empty($keys)) {
105
+                    unset($currentValue[$nextKey]);
106
+                } else {
107
+                    $currentValue[$nextKey] = $this->removeSubValue($keys, $currentValue[$nextKey], $throwError);
108
+                }
109
+            } elseif ($throwError) {
110
+                throw new \UnexpectedValueException('Config parameter does not exist');
111
+            }
112
+        } elseif ($throwError) {
113
+            throw new \UnexpectedValueException('Config parameter does not exist');
114
+        }
115 115
 
116
-		return $currentValue;
117
-	}
116
+        return $currentValue;
117
+    }
118 118
 }
Please login to merge, or discard this patch.
core/Command/Config/Import.php 2 patches
Indentation   +190 added lines, -190 removed lines patch added patch discarded remove patch
@@ -35,194 +35,194 @@
 block discarded – undo
35 35
 use Symfony\Component\Console\Output\OutputInterface;
36 36
 
37 37
 class Import extends Command implements CompletionAwareInterface {
38
-	protected $validRootKeys = ['system', 'apps'];
39
-
40
-	/** @var IConfig */
41
-	protected $config;
42
-
43
-	/**
44
-	 * @param IConfig $config
45
-	 */
46
-	public function __construct(IConfig $config) {
47
-		parent::__construct();
48
-		$this->config = $config;
49
-	}
50
-
51
-	protected function configure() {
52
-		$this
53
-			->setName('config:import')
54
-			->setDescription('Import a list of configs')
55
-			->addArgument(
56
-				'file',
57
-				InputArgument::OPTIONAL,
58
-				'File with the json array to import'
59
-			)
60
-		;
61
-	}
62
-
63
-	protected function execute(InputInterface $input, OutputInterface $output): int {
64
-		$importFile = $input->getArgument('file');
65
-		if ($importFile !== null) {
66
-			$content = $this->getArrayFromFile($importFile);
67
-		} else {
68
-			$content = $this->getArrayFromStdin();
69
-		}
70
-
71
-		try {
72
-			$configs = $this->validateFileContent($content);
73
-		} catch (\UnexpectedValueException $e) {
74
-			$output->writeln('<error>' . $e->getMessage(). '</error>');
75
-			return 1;
76
-		}
77
-
78
-		if (!empty($configs['system'])) {
79
-			$this->config->setSystemValues($configs['system']);
80
-		}
81
-
82
-		if (!empty($configs['apps'])) {
83
-			foreach ($configs['apps'] as $app => $appConfigs) {
84
-				foreach ($appConfigs as $key => $value) {
85
-					if ($value === null) {
86
-						$this->config->deleteAppValue($app, $key);
87
-					} else {
88
-						$this->config->setAppValue($app, $key, $value);
89
-					}
90
-				}
91
-			}
92
-		}
93
-
94
-		$output->writeln('<info>Config successfully imported from: ' . $importFile . '</info>');
95
-		return 0;
96
-	}
97
-
98
-	/**
99
-	 * Get the content from stdin ("config:import < file.json")
100
-	 *
101
-	 * @return string
102
-	 */
103
-	protected function getArrayFromStdin() {
104
-		// Read from stdin. stream_set_blocking is used to prevent blocking
105
-		// when nothing is passed via stdin.
106
-		stream_set_blocking(STDIN, 0);
107
-		$content = file_get_contents('php://stdin');
108
-		stream_set_blocking(STDIN, 1);
109
-		return $content;
110
-	}
111
-
112
-	/**
113
-	 * Get the content of the specified file ("config:import file.json")
114
-	 *
115
-	 * @param string $importFile
116
-	 * @return string
117
-	 */
118
-	protected function getArrayFromFile($importFile) {
119
-		return file_get_contents($importFile);
120
-	}
121
-
122
-	/**
123
-	 * @param string $content
124
-	 * @return array
125
-	 * @throws \UnexpectedValueException when the array is invalid
126
-	 */
127
-	protected function validateFileContent($content) {
128
-		$decodedContent = json_decode($content, true);
129
-		if (!is_array($decodedContent) || empty($decodedContent)) {
130
-			throw new \UnexpectedValueException('The file must contain a valid json array');
131
-		}
132
-
133
-		$this->validateArray($decodedContent);
134
-
135
-		return $decodedContent;
136
-	}
137
-
138
-	/**
139
-	 * Validates that the array only contains `system` and `apps`
140
-	 *
141
-	 * @param array $array
142
-	 */
143
-	protected function validateArray($array) {
144
-		$arrayKeys = array_keys($array);
145
-		$additionalKeys = array_diff($arrayKeys, $this->validRootKeys);
146
-		$commonKeys = array_intersect($arrayKeys, $this->validRootKeys);
147
-		if (!empty($additionalKeys)) {
148
-			throw new \UnexpectedValueException('Found invalid entries in root: ' . implode(', ', $additionalKeys));
149
-		}
150
-		if (empty($commonKeys)) {
151
-			throw new \UnexpectedValueException('At least one key of the following is expected: ' . implode(', ', $this->validRootKeys));
152
-		}
153
-
154
-		if (isset($array['system'])) {
155
-			if (is_array($array['system'])) {
156
-				foreach ($array['system'] as $name => $value) {
157
-					$this->checkTypeRecursively($value, $name);
158
-				}
159
-			} else {
160
-				throw new \UnexpectedValueException('The system config array is not an array');
161
-			}
162
-		}
163
-
164
-		if (isset($array['apps'])) {
165
-			if (is_array($array['apps'])) {
166
-				$this->validateAppsArray($array['apps']);
167
-			} else {
168
-				throw new \UnexpectedValueException('The apps config array is not an array');
169
-			}
170
-		}
171
-	}
172
-
173
-	/**
174
-	 * @param mixed $configValue
175
-	 * @param string $configName
176
-	 */
177
-	protected function checkTypeRecursively($configValue, $configName) {
178
-		if (!is_array($configValue) && !is_bool($configValue) && !is_int($configValue) && !is_string($configValue) && !is_null($configValue)) {
179
-			throw new \UnexpectedValueException('Invalid system config value for "' . $configName . '". Only arrays, bools, integers, strings and null (delete) are allowed.');
180
-		}
181
-		if (is_array($configValue)) {
182
-			foreach ($configValue as $key => $value) {
183
-				$this->checkTypeRecursively($value, $configName);
184
-			}
185
-		}
186
-	}
187
-
188
-	/**
189
-	 * Validates that app configs are only integers and strings
190
-	 *
191
-	 * @param array $array
192
-	 */
193
-	protected function validateAppsArray($array) {
194
-		foreach ($array as $app => $configs) {
195
-			foreach ($configs as $name => $value) {
196
-				if (!is_int($value) && !is_string($value) && !is_null($value)) {
197
-					throw new \UnexpectedValueException('Invalid app config value for "' . $app . '":"' . $name . '". Only integers, strings and null (delete) are allowed.');
198
-				}
199
-			}
200
-		}
201
-	}
202
-
203
-	/**
204
-	 * @param string $optionName
205
-	 * @param CompletionContext $context
206
-	 * @return string[]
207
-	 */
208
-	public function completeOptionValues($optionName, CompletionContext $context) {
209
-		return [];
210
-	}
211
-
212
-	/**
213
-	 * @param string $argumentName
214
-	 * @param CompletionContext $context
215
-	 * @return string[]
216
-	 */
217
-	public function completeArgumentValues($argumentName, CompletionContext $context) {
218
-		if ($argumentName === 'file') {
219
-			$helper = new ShellPathCompletion(
220
-				$this->getName(),
221
-				'file',
222
-				Completion::TYPE_ARGUMENT
223
-			);
224
-			return $helper->run();
225
-		}
226
-		return [];
227
-	}
38
+    protected $validRootKeys = ['system', 'apps'];
39
+
40
+    /** @var IConfig */
41
+    protected $config;
42
+
43
+    /**
44
+     * @param IConfig $config
45
+     */
46
+    public function __construct(IConfig $config) {
47
+        parent::__construct();
48
+        $this->config = $config;
49
+    }
50
+
51
+    protected function configure() {
52
+        $this
53
+            ->setName('config:import')
54
+            ->setDescription('Import a list of configs')
55
+            ->addArgument(
56
+                'file',
57
+                InputArgument::OPTIONAL,
58
+                'File with the json array to import'
59
+            )
60
+        ;
61
+    }
62
+
63
+    protected function execute(InputInterface $input, OutputInterface $output): int {
64
+        $importFile = $input->getArgument('file');
65
+        if ($importFile !== null) {
66
+            $content = $this->getArrayFromFile($importFile);
67
+        } else {
68
+            $content = $this->getArrayFromStdin();
69
+        }
70
+
71
+        try {
72
+            $configs = $this->validateFileContent($content);
73
+        } catch (\UnexpectedValueException $e) {
74
+            $output->writeln('<error>' . $e->getMessage(). '</error>');
75
+            return 1;
76
+        }
77
+
78
+        if (!empty($configs['system'])) {
79
+            $this->config->setSystemValues($configs['system']);
80
+        }
81
+
82
+        if (!empty($configs['apps'])) {
83
+            foreach ($configs['apps'] as $app => $appConfigs) {
84
+                foreach ($appConfigs as $key => $value) {
85
+                    if ($value === null) {
86
+                        $this->config->deleteAppValue($app, $key);
87
+                    } else {
88
+                        $this->config->setAppValue($app, $key, $value);
89
+                    }
90
+                }
91
+            }
92
+        }
93
+
94
+        $output->writeln('<info>Config successfully imported from: ' . $importFile . '</info>');
95
+        return 0;
96
+    }
97
+
98
+    /**
99
+     * Get the content from stdin ("config:import < file.json")
100
+     *
101
+     * @return string
102
+     */
103
+    protected function getArrayFromStdin() {
104
+        // Read from stdin. stream_set_blocking is used to prevent blocking
105
+        // when nothing is passed via stdin.
106
+        stream_set_blocking(STDIN, 0);
107
+        $content = file_get_contents('php://stdin');
108
+        stream_set_blocking(STDIN, 1);
109
+        return $content;
110
+    }
111
+
112
+    /**
113
+     * Get the content of the specified file ("config:import file.json")
114
+     *
115
+     * @param string $importFile
116
+     * @return string
117
+     */
118
+    protected function getArrayFromFile($importFile) {
119
+        return file_get_contents($importFile);
120
+    }
121
+
122
+    /**
123
+     * @param string $content
124
+     * @return array
125
+     * @throws \UnexpectedValueException when the array is invalid
126
+     */
127
+    protected function validateFileContent($content) {
128
+        $decodedContent = json_decode($content, true);
129
+        if (!is_array($decodedContent) || empty($decodedContent)) {
130
+            throw new \UnexpectedValueException('The file must contain a valid json array');
131
+        }
132
+
133
+        $this->validateArray($decodedContent);
134
+
135
+        return $decodedContent;
136
+    }
137
+
138
+    /**
139
+     * Validates that the array only contains `system` and `apps`
140
+     *
141
+     * @param array $array
142
+     */
143
+    protected function validateArray($array) {
144
+        $arrayKeys = array_keys($array);
145
+        $additionalKeys = array_diff($arrayKeys, $this->validRootKeys);
146
+        $commonKeys = array_intersect($arrayKeys, $this->validRootKeys);
147
+        if (!empty($additionalKeys)) {
148
+            throw new \UnexpectedValueException('Found invalid entries in root: ' . implode(', ', $additionalKeys));
149
+        }
150
+        if (empty($commonKeys)) {
151
+            throw new \UnexpectedValueException('At least one key of the following is expected: ' . implode(', ', $this->validRootKeys));
152
+        }
153
+
154
+        if (isset($array['system'])) {
155
+            if (is_array($array['system'])) {
156
+                foreach ($array['system'] as $name => $value) {
157
+                    $this->checkTypeRecursively($value, $name);
158
+                }
159
+            } else {
160
+                throw new \UnexpectedValueException('The system config array is not an array');
161
+            }
162
+        }
163
+
164
+        if (isset($array['apps'])) {
165
+            if (is_array($array['apps'])) {
166
+                $this->validateAppsArray($array['apps']);
167
+            } else {
168
+                throw new \UnexpectedValueException('The apps config array is not an array');
169
+            }
170
+        }
171
+    }
172
+
173
+    /**
174
+     * @param mixed $configValue
175
+     * @param string $configName
176
+     */
177
+    protected function checkTypeRecursively($configValue, $configName) {
178
+        if (!is_array($configValue) && !is_bool($configValue) && !is_int($configValue) && !is_string($configValue) && !is_null($configValue)) {
179
+            throw new \UnexpectedValueException('Invalid system config value for "' . $configName . '". Only arrays, bools, integers, strings and null (delete) are allowed.');
180
+        }
181
+        if (is_array($configValue)) {
182
+            foreach ($configValue as $key => $value) {
183
+                $this->checkTypeRecursively($value, $configName);
184
+            }
185
+        }
186
+    }
187
+
188
+    /**
189
+     * Validates that app configs are only integers and strings
190
+     *
191
+     * @param array $array
192
+     */
193
+    protected function validateAppsArray($array) {
194
+        foreach ($array as $app => $configs) {
195
+            foreach ($configs as $name => $value) {
196
+                if (!is_int($value) && !is_string($value) && !is_null($value)) {
197
+                    throw new \UnexpectedValueException('Invalid app config value for "' . $app . '":"' . $name . '". Only integers, strings and null (delete) are allowed.');
198
+                }
199
+            }
200
+        }
201
+    }
202
+
203
+    /**
204
+     * @param string $optionName
205
+     * @param CompletionContext $context
206
+     * @return string[]
207
+     */
208
+    public function completeOptionValues($optionName, CompletionContext $context) {
209
+        return [];
210
+    }
211
+
212
+    /**
213
+     * @param string $argumentName
214
+     * @param CompletionContext $context
215
+     * @return string[]
216
+     */
217
+    public function completeArgumentValues($argumentName, CompletionContext $context) {
218
+        if ($argumentName === 'file') {
219
+            $helper = new ShellPathCompletion(
220
+                $this->getName(),
221
+                'file',
222
+                Completion::TYPE_ARGUMENT
223
+            );
224
+            return $helper->run();
225
+        }
226
+        return [];
227
+    }
228 228
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 		try {
72 72
 			$configs = $this->validateFileContent($content);
73 73
 		} catch (\UnexpectedValueException $e) {
74
-			$output->writeln('<error>' . $e->getMessage(). '</error>');
74
+			$output->writeln('<error>'.$e->getMessage().'</error>');
75 75
 			return 1;
76 76
 		}
77 77
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 			}
92 92
 		}
93 93
 
94
-		$output->writeln('<info>Config successfully imported from: ' . $importFile . '</info>');
94
+		$output->writeln('<info>Config successfully imported from: '.$importFile.'</info>');
95 95
 		return 0;
96 96
 	}
97 97
 
@@ -145,10 +145,10 @@  discard block
 block discarded – undo
145 145
 		$additionalKeys = array_diff($arrayKeys, $this->validRootKeys);
146 146
 		$commonKeys = array_intersect($arrayKeys, $this->validRootKeys);
147 147
 		if (!empty($additionalKeys)) {
148
-			throw new \UnexpectedValueException('Found invalid entries in root: ' . implode(', ', $additionalKeys));
148
+			throw new \UnexpectedValueException('Found invalid entries in root: '.implode(', ', $additionalKeys));
149 149
 		}
150 150
 		if (empty($commonKeys)) {
151
-			throw new \UnexpectedValueException('At least one key of the following is expected: ' . implode(', ', $this->validRootKeys));
151
+			throw new \UnexpectedValueException('At least one key of the following is expected: '.implode(', ', $this->validRootKeys));
152 152
 		}
153 153
 
154 154
 		if (isset($array['system'])) {
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 	 */
177 177
 	protected function checkTypeRecursively($configValue, $configName) {
178 178
 		if (!is_array($configValue) && !is_bool($configValue) && !is_int($configValue) && !is_string($configValue) && !is_null($configValue)) {
179
-			throw new \UnexpectedValueException('Invalid system config value for "' . $configName . '". Only arrays, bools, integers, strings and null (delete) are allowed.');
179
+			throw new \UnexpectedValueException('Invalid system config value for "'.$configName.'". Only arrays, bools, integers, strings and null (delete) are allowed.');
180 180
 		}
181 181
 		if (is_array($configValue)) {
182 182
 			foreach ($configValue as $key => $value) {
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 		foreach ($array as $app => $configs) {
195 195
 			foreach ($configs as $name => $value) {
196 196
 				if (!is_int($value) && !is_string($value) && !is_null($value)) {
197
-					throw new \UnexpectedValueException('Invalid app config value for "' . $app . '":"' . $name . '". Only integers, strings and null (delete) are allowed.');
197
+					throw new \UnexpectedValueException('Invalid app config value for "'.$app.'":"'.$name.'". Only integers, strings and null (delete) are allowed.');
198 198
 				}
199 199
 			}
200 200
 		}
Please login to merge, or discard this patch.
core/Command/Maintenance/Install.php 1 patch
Indentation   +161 added lines, -161 removed lines patch added patch discarded remove patch
@@ -46,165 +46,165 @@
 block discarded – undo
46 46
 
47 47
 class Install extends Command {
48 48
 
49
-	/**
50
-	 * @var SystemConfig
51
-	 */
52
-	private $config;
53
-
54
-	public function __construct(SystemConfig $config) {
55
-		parent::__construct();
56
-		$this->config = $config;
57
-	}
58
-
59
-	protected function configure() {
60
-		$this
61
-			->setName('maintenance:install')
62
-			->setDescription('install Nextcloud')
63
-			->addOption('database', null, InputOption::VALUE_REQUIRED, 'Supported database type', 'sqlite')
64
-			->addOption('database-name', null, InputOption::VALUE_REQUIRED, 'Name of the database')
65
-			->addOption('database-host', null, InputOption::VALUE_REQUIRED, 'Hostname of the database', 'localhost')
66
-			->addOption('database-port', null, InputOption::VALUE_REQUIRED, 'Port the database is listening on')
67
-			->addOption('database-user', null, InputOption::VALUE_REQUIRED, 'User name to connect to the database')
68
-			->addOption('database-pass', null, InputOption::VALUE_OPTIONAL, 'Password of the database user', null)
69
-			->addOption('database-table-space', null, InputOption::VALUE_OPTIONAL, 'Table space of the database (oci only)', null)
70
-			->addOption('admin-user', null, InputOption::VALUE_REQUIRED, 'User name of the admin account', 'admin')
71
-			->addOption('admin-pass', null, InputOption::VALUE_REQUIRED, 'Password of the admin account')
72
-			->addOption('admin-email', null, InputOption::VALUE_OPTIONAL, 'E-Mail of the admin account')
73
-			->addOption('data-dir', null, InputOption::VALUE_REQUIRED, 'Path to data directory', \OC::$SERVERROOT."/data");
74
-	}
75
-
76
-	protected function execute(InputInterface $input, OutputInterface $output): int {
77
-
78
-		// validate the environment
79
-		$server = \OC::$server;
80
-		$setupHelper = new Setup(
81
-			$this->config,
82
-			$server->getIniWrapper(),
83
-			$server->getL10N('lib'),
84
-			$server->query(Defaults::class),
85
-			$server->getLogger(),
86
-			$server->getSecureRandom(),
87
-			\OC::$server->query(Installer::class)
88
-		);
89
-		$sysInfo = $setupHelper->getSystemInfo(true);
90
-		$errors = $sysInfo['errors'];
91
-		if (count($errors) > 0) {
92
-			$this->printErrors($output, $errors);
93
-
94
-			// ignore the OS X setup warning
95
-			if (count($errors) !== 1 ||
96
-				(string)$errors[0]['error'] !== 'Mac OS X is not supported and Nextcloud will not work properly on this platform. Use it at your own risk! ') {
97
-				return 1;
98
-			}
99
-		}
100
-
101
-		// validate user input
102
-		$options = $this->validateInput($input, $output, array_keys($sysInfo['databases']));
103
-
104
-		// perform installation
105
-		$errors = $setupHelper->install($options);
106
-		if (count($errors) > 0) {
107
-			$this->printErrors($output, $errors);
108
-			return 1;
109
-		}
110
-		$output->writeln("Nextcloud was successfully installed");
111
-		return 0;
112
-	}
113
-
114
-	/**
115
-	 * @param InputInterface $input
116
-	 * @param OutputInterface $output
117
-	 * @param string[] $supportedDatabases
118
-	 * @return array
119
-	 */
120
-	protected function validateInput(InputInterface $input, OutputInterface $output, $supportedDatabases) {
121
-		$db = strtolower($input->getOption('database'));
122
-
123
-		if (!in_array($db, $supportedDatabases)) {
124
-			throw new InvalidArgumentException("Database <$db> is not supported.");
125
-		}
126
-
127
-		$dbUser = $input->getOption('database-user');
128
-		$dbPass = $input->getOption('database-pass');
129
-		$dbName = $input->getOption('database-name');
130
-		$dbPort = $input->getOption('database-port');
131
-		if ($db === 'oci') {
132
-			// an empty hostname needs to be read from the raw parameters
133
-			$dbHost = $input->getParameterOption('--database-host', '');
134
-		} else {
135
-			$dbHost = $input->getOption('database-host');
136
-		}
137
-		if ($dbPort) {
138
-			// Append the port to the host so it is the same as in the config (there is no dbport config)
139
-			$dbHost .= ':' . $dbPort;
140
-		}
141
-		if ($input->hasParameterOption('--database-pass')) {
142
-			$dbPass = (string) $input->getOption('database-pass');
143
-		}
144
-		$adminLogin = $input->getOption('admin-user');
145
-		$adminPassword = $input->getOption('admin-pass');
146
-		$adminEmail = $input->getOption('admin-email');
147
-		$dataDir = $input->getOption('data-dir');
148
-
149
-		if ($db !== 'sqlite') {
150
-			if (is_null($dbUser)) {
151
-				throw new InvalidArgumentException("Database user not provided.");
152
-			}
153
-			if (is_null($dbName)) {
154
-				throw new InvalidArgumentException("Database name not provided.");
155
-			}
156
-			if (is_null($dbPass)) {
157
-				/** @var QuestionHelper $helper */
158
-				$helper = $this->getHelper('question');
159
-				$question = new Question('What is the password to access the database with user <'.$dbUser.'>?');
160
-				$question->setHidden(true);
161
-				$question->setHiddenFallback(false);
162
-				$dbPass = $helper->ask($input, $output, $question);
163
-			}
164
-		}
165
-
166
-		if (is_null($adminPassword)) {
167
-			/** @var QuestionHelper $helper */
168
-			$helper = $this->getHelper('question');
169
-			$question = new Question('What is the password you like to use for the admin account <'.$adminLogin.'>?');
170
-			$question->setHidden(true);
171
-			$question->setHiddenFallback(false);
172
-			$adminPassword = $helper->ask($input, $output, $question);
173
-		}
174
-
175
-		if ($adminEmail !== null && !filter_var($adminEmail, FILTER_VALIDATE_EMAIL)) {
176
-			throw new InvalidArgumentException('Invalid e-mail-address <' . $adminEmail . '> for <' . $adminLogin . '>.');
177
-		}
178
-
179
-		$options = [
180
-			'dbtype' => $db,
181
-			'dbuser' => $dbUser,
182
-			'dbpass' => $dbPass,
183
-			'dbname' => $dbName,
184
-			'dbhost' => $dbHost,
185
-			'adminlogin' => $adminLogin,
186
-			'adminpass' => $adminPassword,
187
-			'adminemail' => $adminEmail,
188
-			'directory' => $dataDir
189
-		];
190
-		if ($db === 'oci') {
191
-			$options['dbtablespace'] = $input->getParameterOption('--database-table-space', '');
192
-		}
193
-		return $options;
194
-	}
195
-
196
-	/**
197
-	 * @param OutputInterface $output
198
-	 * @param $errors
199
-	 */
200
-	protected function printErrors(OutputInterface $output, $errors) {
201
-		foreach ($errors as $error) {
202
-			if (is_array($error)) {
203
-				$output->writeln('<error>' . (string)$error['error'] . '</error>');
204
-				$output->writeln('<info> -> ' . (string)$error['hint'] . '</info>');
205
-			} else {
206
-				$output->writeln('<error>' . (string)$error . '</error>');
207
-			}
208
-		}
209
-	}
49
+    /**
50
+     * @var SystemConfig
51
+     */
52
+    private $config;
53
+
54
+    public function __construct(SystemConfig $config) {
55
+        parent::__construct();
56
+        $this->config = $config;
57
+    }
58
+
59
+    protected function configure() {
60
+        $this
61
+            ->setName('maintenance:install')
62
+            ->setDescription('install Nextcloud')
63
+            ->addOption('database', null, InputOption::VALUE_REQUIRED, 'Supported database type', 'sqlite')
64
+            ->addOption('database-name', null, InputOption::VALUE_REQUIRED, 'Name of the database')
65
+            ->addOption('database-host', null, InputOption::VALUE_REQUIRED, 'Hostname of the database', 'localhost')
66
+            ->addOption('database-port', null, InputOption::VALUE_REQUIRED, 'Port the database is listening on')
67
+            ->addOption('database-user', null, InputOption::VALUE_REQUIRED, 'User name to connect to the database')
68
+            ->addOption('database-pass', null, InputOption::VALUE_OPTIONAL, 'Password of the database user', null)
69
+            ->addOption('database-table-space', null, InputOption::VALUE_OPTIONAL, 'Table space of the database (oci only)', null)
70
+            ->addOption('admin-user', null, InputOption::VALUE_REQUIRED, 'User name of the admin account', 'admin')
71
+            ->addOption('admin-pass', null, InputOption::VALUE_REQUIRED, 'Password of the admin account')
72
+            ->addOption('admin-email', null, InputOption::VALUE_OPTIONAL, 'E-Mail of the admin account')
73
+            ->addOption('data-dir', null, InputOption::VALUE_REQUIRED, 'Path to data directory', \OC::$SERVERROOT."/data");
74
+    }
75
+
76
+    protected function execute(InputInterface $input, OutputInterface $output): int {
77
+
78
+        // validate the environment
79
+        $server = \OC::$server;
80
+        $setupHelper = new Setup(
81
+            $this->config,
82
+            $server->getIniWrapper(),
83
+            $server->getL10N('lib'),
84
+            $server->query(Defaults::class),
85
+            $server->getLogger(),
86
+            $server->getSecureRandom(),
87
+            \OC::$server->query(Installer::class)
88
+        );
89
+        $sysInfo = $setupHelper->getSystemInfo(true);
90
+        $errors = $sysInfo['errors'];
91
+        if (count($errors) > 0) {
92
+            $this->printErrors($output, $errors);
93
+
94
+            // ignore the OS X setup warning
95
+            if (count($errors) !== 1 ||
96
+                (string)$errors[0]['error'] !== 'Mac OS X is not supported and Nextcloud will not work properly on this platform. Use it at your own risk! ') {
97
+                return 1;
98
+            }
99
+        }
100
+
101
+        // validate user input
102
+        $options = $this->validateInput($input, $output, array_keys($sysInfo['databases']));
103
+
104
+        // perform installation
105
+        $errors = $setupHelper->install($options);
106
+        if (count($errors) > 0) {
107
+            $this->printErrors($output, $errors);
108
+            return 1;
109
+        }
110
+        $output->writeln("Nextcloud was successfully installed");
111
+        return 0;
112
+    }
113
+
114
+    /**
115
+     * @param InputInterface $input
116
+     * @param OutputInterface $output
117
+     * @param string[] $supportedDatabases
118
+     * @return array
119
+     */
120
+    protected function validateInput(InputInterface $input, OutputInterface $output, $supportedDatabases) {
121
+        $db = strtolower($input->getOption('database'));
122
+
123
+        if (!in_array($db, $supportedDatabases)) {
124
+            throw new InvalidArgumentException("Database <$db> is not supported.");
125
+        }
126
+
127
+        $dbUser = $input->getOption('database-user');
128
+        $dbPass = $input->getOption('database-pass');
129
+        $dbName = $input->getOption('database-name');
130
+        $dbPort = $input->getOption('database-port');
131
+        if ($db === 'oci') {
132
+            // an empty hostname needs to be read from the raw parameters
133
+            $dbHost = $input->getParameterOption('--database-host', '');
134
+        } else {
135
+            $dbHost = $input->getOption('database-host');
136
+        }
137
+        if ($dbPort) {
138
+            // Append the port to the host so it is the same as in the config (there is no dbport config)
139
+            $dbHost .= ':' . $dbPort;
140
+        }
141
+        if ($input->hasParameterOption('--database-pass')) {
142
+            $dbPass = (string) $input->getOption('database-pass');
143
+        }
144
+        $adminLogin = $input->getOption('admin-user');
145
+        $adminPassword = $input->getOption('admin-pass');
146
+        $adminEmail = $input->getOption('admin-email');
147
+        $dataDir = $input->getOption('data-dir');
148
+
149
+        if ($db !== 'sqlite') {
150
+            if (is_null($dbUser)) {
151
+                throw new InvalidArgumentException("Database user not provided.");
152
+            }
153
+            if (is_null($dbName)) {
154
+                throw new InvalidArgumentException("Database name not provided.");
155
+            }
156
+            if (is_null($dbPass)) {
157
+                /** @var QuestionHelper $helper */
158
+                $helper = $this->getHelper('question');
159
+                $question = new Question('What is the password to access the database with user <'.$dbUser.'>?');
160
+                $question->setHidden(true);
161
+                $question->setHiddenFallback(false);
162
+                $dbPass = $helper->ask($input, $output, $question);
163
+            }
164
+        }
165
+
166
+        if (is_null($adminPassword)) {
167
+            /** @var QuestionHelper $helper */
168
+            $helper = $this->getHelper('question');
169
+            $question = new Question('What is the password you like to use for the admin account <'.$adminLogin.'>?');
170
+            $question->setHidden(true);
171
+            $question->setHiddenFallback(false);
172
+            $adminPassword = $helper->ask($input, $output, $question);
173
+        }
174
+
175
+        if ($adminEmail !== null && !filter_var($adminEmail, FILTER_VALIDATE_EMAIL)) {
176
+            throw new InvalidArgumentException('Invalid e-mail-address <' . $adminEmail . '> for <' . $adminLogin . '>.');
177
+        }
178
+
179
+        $options = [
180
+            'dbtype' => $db,
181
+            'dbuser' => $dbUser,
182
+            'dbpass' => $dbPass,
183
+            'dbname' => $dbName,
184
+            'dbhost' => $dbHost,
185
+            'adminlogin' => $adminLogin,
186
+            'adminpass' => $adminPassword,
187
+            'adminemail' => $adminEmail,
188
+            'directory' => $dataDir
189
+        ];
190
+        if ($db === 'oci') {
191
+            $options['dbtablespace'] = $input->getParameterOption('--database-table-space', '');
192
+        }
193
+        return $options;
194
+    }
195
+
196
+    /**
197
+     * @param OutputInterface $output
198
+     * @param $errors
199
+     */
200
+    protected function printErrors(OutputInterface $output, $errors) {
201
+        foreach ($errors as $error) {
202
+            if (is_array($error)) {
203
+                $output->writeln('<error>' . (string)$error['error'] . '</error>');
204
+                $output->writeln('<info> -> ' . (string)$error['hint'] . '</info>');
205
+            } else {
206
+                $output->writeln('<error>' . (string)$error . '</error>');
207
+            }
208
+        }
209
+    }
210 210
 }
Please login to merge, or discard this patch.
core/Command/Maintenance/Mimetype/UpdateDB.php 1 patch
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -33,68 +33,68 @@
 block discarded – undo
33 33
 use Symfony\Component\Console\Output\OutputInterface;
34 34
 
35 35
 class UpdateDB extends Command {
36
-	public const DEFAULT_MIMETYPE = 'application/octet-stream';
36
+    public const DEFAULT_MIMETYPE = 'application/octet-stream';
37 37
 
38
-	/** @var IMimeTypeDetector */
39
-	protected $mimetypeDetector;
38
+    /** @var IMimeTypeDetector */
39
+    protected $mimetypeDetector;
40 40
 
41
-	/** @var IMimeTypeLoader */
42
-	protected $mimetypeLoader;
41
+    /** @var IMimeTypeLoader */
42
+    protected $mimetypeLoader;
43 43
 
44
-	public function __construct(
45
-		IMimeTypeDetector $mimetypeDetector,
46
-		IMimeTypeLoader $mimetypeLoader
47
-	) {
48
-		parent::__construct();
49
-		$this->mimetypeDetector = $mimetypeDetector;
50
-		$this->mimetypeLoader = $mimetypeLoader;
51
-	}
44
+    public function __construct(
45
+        IMimeTypeDetector $mimetypeDetector,
46
+        IMimeTypeLoader $mimetypeLoader
47
+    ) {
48
+        parent::__construct();
49
+        $this->mimetypeDetector = $mimetypeDetector;
50
+        $this->mimetypeLoader = $mimetypeLoader;
51
+    }
52 52
 
53
-	protected function configure() {
54
-		$this
55
-			->setName('maintenance:mimetype:update-db')
56
-			->setDescription('Update database mimetypes and update filecache')
57
-			->addOption(
58
-				'repair-filecache',
59
-				null,
60
-				InputOption::VALUE_NONE,
61
-				'Repair filecache for all mimetypes, not just new ones'
62
-			)
63
-		;
64
-	}
53
+    protected function configure() {
54
+        $this
55
+            ->setName('maintenance:mimetype:update-db')
56
+            ->setDescription('Update database mimetypes and update filecache')
57
+            ->addOption(
58
+                'repair-filecache',
59
+                null,
60
+                InputOption::VALUE_NONE,
61
+                'Repair filecache for all mimetypes, not just new ones'
62
+            )
63
+        ;
64
+    }
65 65
 
66
-	protected function execute(InputInterface $input, OutputInterface $output): int {
67
-		$mappings = $this->mimetypeDetector->getAllMappings();
66
+    protected function execute(InputInterface $input, OutputInterface $output): int {
67
+        $mappings = $this->mimetypeDetector->getAllMappings();
68 68
 
69
-		$totalFilecacheUpdates = 0;
70
-		$totalNewMimetypes = 0;
69
+        $totalFilecacheUpdates = 0;
70
+        $totalNewMimetypes = 0;
71 71
 
72
-		foreach ($mappings as $ext => $mimetypes) {
73
-			if ($ext[0] === '_') {
74
-				// comment
75
-				continue;
76
-			}
77
-			$mimetype = $mimetypes[0];
78
-			$existing = $this->mimetypeLoader->exists($mimetype);
79
-			// this will add the mimetype if it didn't exist
80
-			$mimetypeId = $this->mimetypeLoader->getId($mimetype);
72
+        foreach ($mappings as $ext => $mimetypes) {
73
+            if ($ext[0] === '_') {
74
+                // comment
75
+                continue;
76
+            }
77
+            $mimetype = $mimetypes[0];
78
+            $existing = $this->mimetypeLoader->exists($mimetype);
79
+            // this will add the mimetype if it didn't exist
80
+            $mimetypeId = $this->mimetypeLoader->getId($mimetype);
81 81
 
82
-			if (!$existing) {
83
-				$output->writeln('Added mimetype "'.$mimetype.'" to database');
84
-				$totalNewMimetypes++;
85
-			}
82
+            if (!$existing) {
83
+                $output->writeln('Added mimetype "'.$mimetype.'" to database');
84
+                $totalNewMimetypes++;
85
+            }
86 86
 
87
-			if (!$existing || $input->getOption('repair-filecache')) {
88
-				$touchedFilecacheRows = $this->mimetypeLoader->updateFilecache($ext, $mimetypeId);
89
-				if ($touchedFilecacheRows > 0) {
90
-					$output->writeln('Updated '.$touchedFilecacheRows.' filecache rows for mimetype "'.$mimetype.'"');
91
-				}
92
-				$totalFilecacheUpdates += $touchedFilecacheRows;
93
-			}
94
-		}
87
+            if (!$existing || $input->getOption('repair-filecache')) {
88
+                $touchedFilecacheRows = $this->mimetypeLoader->updateFilecache($ext, $mimetypeId);
89
+                if ($touchedFilecacheRows > 0) {
90
+                    $output->writeln('Updated '.$touchedFilecacheRows.' filecache rows for mimetype "'.$mimetype.'"');
91
+                }
92
+                $totalFilecacheUpdates += $touchedFilecacheRows;
93
+            }
94
+        }
95 95
 
96
-		$output->writeln('Added '.$totalNewMimetypes.' new mimetypes');
97
-		$output->writeln('Updated '.$totalFilecacheUpdates.' filecache rows');
98
-		return 0;
99
-	}
96
+        $output->writeln('Added '.$totalNewMimetypes.' new mimetypes');
97
+        $output->writeln('Updated '.$totalFilecacheUpdates.' filecache rows');
98
+        return 0;
99
+    }
100 100
 }
Please login to merge, or discard this patch.
core/Command/Maintenance/Mimetype/UpdateJS.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -32,31 +32,31 @@
 block discarded – undo
32 32
 
33 33
 class UpdateJS extends Command {
34 34
 
35
-	/** @var IMimeTypeDetector */
36
-	protected $mimetypeDetector;
37
-
38
-	public function __construct(
39
-		IMimeTypeDetector $mimetypeDetector
40
-	) {
41
-		parent::__construct();
42
-		$this->mimetypeDetector = $mimetypeDetector;
43
-	}
44
-
45
-	protected function configure() {
46
-		$this
47
-			->setName('maintenance:mimetype:update-js')
48
-			->setDescription('Update mimetypelist.js');
49
-	}
50
-
51
-	protected function execute(InputInterface $input, OutputInterface $output): int {
52
-		// Fetch all the aliases
53
-		$aliases = $this->mimetypeDetector->getAllAliases();
54
-
55
-		// Output the JS
56
-		$generatedMimetypeFile = new GenerateMimetypeFileBuilder();
57
-		file_put_contents(\OC::$SERVERROOT.'/core/js/mimetypelist.js', $generatedMimetypeFile->generateFile($aliases));
58
-
59
-		$output->writeln('<info>mimetypelist.js is updated');
60
-		return 0;
61
-	}
35
+    /** @var IMimeTypeDetector */
36
+    protected $mimetypeDetector;
37
+
38
+    public function __construct(
39
+        IMimeTypeDetector $mimetypeDetector
40
+    ) {
41
+        parent::__construct();
42
+        $this->mimetypeDetector = $mimetypeDetector;
43
+    }
44
+
45
+    protected function configure() {
46
+        $this
47
+            ->setName('maintenance:mimetype:update-js')
48
+            ->setDescription('Update mimetypelist.js');
49
+    }
50
+
51
+    protected function execute(InputInterface $input, OutputInterface $output): int {
52
+        // Fetch all the aliases
53
+        $aliases = $this->mimetypeDetector->getAllAliases();
54
+
55
+        // Output the JS
56
+        $generatedMimetypeFile = new GenerateMimetypeFileBuilder();
57
+        file_put_contents(\OC::$SERVERROOT.'/core/js/mimetypelist.js', $generatedMimetypeFile->generateFile($aliases));
58
+
59
+        $output->writeln('<info>mimetypelist.js is updated');
60
+        return 0;
61
+    }
62 62
 }
Please login to merge, or discard this patch.
core/Command/Maintenance/Repair.php 1 patch
Indentation   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -41,121 +41,121 @@
 block discarded – undo
41 41
 use Symfony\Component\EventDispatcher\GenericEvent;
42 42
 
43 43
 class Repair extends Command {
44
-	/** @var \OC\Repair $repair */
45
-	protected $repair;
46
-	/** @var IConfig */
47
-	protected $config;
48
-	/** @var EventDispatcherInterface */
49
-	private $dispatcher;
50
-	/** @var ProgressBar */
51
-	private $progress;
52
-	/** @var OutputInterface */
53
-	private $output;
54
-	/** @var IAppManager */
55
-	private $appManager;
44
+    /** @var \OC\Repair $repair */
45
+    protected $repair;
46
+    /** @var IConfig */
47
+    protected $config;
48
+    /** @var EventDispatcherInterface */
49
+    private $dispatcher;
50
+    /** @var ProgressBar */
51
+    private $progress;
52
+    /** @var OutputInterface */
53
+    private $output;
54
+    /** @var IAppManager */
55
+    private $appManager;
56 56
 
57
-	/**
58
-	 * @param \OC\Repair $repair
59
-	 * @param IConfig $config
60
-	 * @param EventDispatcherInterface $dispatcher
61
-	 * @param IAppManager $appManager
62
-	 */
63
-	public function __construct(\OC\Repair $repair, IConfig $config, EventDispatcherInterface $dispatcher, IAppManager $appManager) {
64
-		$this->repair = $repair;
65
-		$this->config = $config;
66
-		$this->dispatcher = $dispatcher;
67
-		$this->appManager = $appManager;
68
-		parent::__construct();
69
-	}
57
+    /**
58
+     * @param \OC\Repair $repair
59
+     * @param IConfig $config
60
+     * @param EventDispatcherInterface $dispatcher
61
+     * @param IAppManager $appManager
62
+     */
63
+    public function __construct(\OC\Repair $repair, IConfig $config, EventDispatcherInterface $dispatcher, IAppManager $appManager) {
64
+        $this->repair = $repair;
65
+        $this->config = $config;
66
+        $this->dispatcher = $dispatcher;
67
+        $this->appManager = $appManager;
68
+        parent::__construct();
69
+    }
70 70
 
71
-	protected function configure() {
72
-		$this
73
-			->setName('maintenance:repair')
74
-			->setDescription('repair this installation')
75
-			->addOption(
76
-				'include-expensive',
77
-				null,
78
-				InputOption::VALUE_NONE,
79
-				'Use this option when you want to include resource and load expensive tasks');
80
-	}
71
+    protected function configure() {
72
+        $this
73
+            ->setName('maintenance:repair')
74
+            ->setDescription('repair this installation')
75
+            ->addOption(
76
+                'include-expensive',
77
+                null,
78
+                InputOption::VALUE_NONE,
79
+                'Use this option when you want to include resource and load expensive tasks');
80
+    }
81 81
 
82
-	protected function execute(InputInterface $input, OutputInterface $output): int {
83
-		$repairSteps = $this->repair::getRepairSteps();
82
+    protected function execute(InputInterface $input, OutputInterface $output): int {
83
+        $repairSteps = $this->repair::getRepairSteps();
84 84
 
85
-		if ($input->getOption('include-expensive')) {
86
-			$repairSteps = array_merge($repairSteps, $this->repair::getExpensiveRepairSteps());
87
-		}
85
+        if ($input->getOption('include-expensive')) {
86
+            $repairSteps = array_merge($repairSteps, $this->repair::getExpensiveRepairSteps());
87
+        }
88 88
 
89
-		foreach ($repairSteps as $step) {
90
-			$this->repair->addStep($step);
91
-		}
89
+        foreach ($repairSteps as $step) {
90
+            $this->repair->addStep($step);
91
+        }
92 92
 
93
-		$apps = $this->appManager->getInstalledApps();
94
-		foreach ($apps as $app) {
95
-			if (!$this->appManager->isEnabledForUser($app)) {
96
-				continue;
97
-			}
98
-			$info = \OC_App::getAppInfo($app);
99
-			if (!is_array($info)) {
100
-				continue;
101
-			}
102
-			\OC_App::loadApp($app);
103
-			$steps = $info['repair-steps']['post-migration'];
104
-			foreach ($steps as $step) {
105
-				try {
106
-					$this->repair->addStep($step);
107
-				} catch (Exception $ex) {
108
-					$output->writeln("<error>Failed to load repair step for $app: {$ex->getMessage()}</error>");
109
-				}
110
-			}
111
-		}
93
+        $apps = $this->appManager->getInstalledApps();
94
+        foreach ($apps as $app) {
95
+            if (!$this->appManager->isEnabledForUser($app)) {
96
+                continue;
97
+            }
98
+            $info = \OC_App::getAppInfo($app);
99
+            if (!is_array($info)) {
100
+                continue;
101
+            }
102
+            \OC_App::loadApp($app);
103
+            $steps = $info['repair-steps']['post-migration'];
104
+            foreach ($steps as $step) {
105
+                try {
106
+                    $this->repair->addStep($step);
107
+                } catch (Exception $ex) {
108
+                    $output->writeln("<error>Failed to load repair step for $app: {$ex->getMessage()}</error>");
109
+                }
110
+            }
111
+        }
112 112
 
113
-		$maintenanceMode = $this->config->getSystemValueBool('maintenance');
114
-		$this->config->setSystemValue('maintenance', true);
113
+        $maintenanceMode = $this->config->getSystemValueBool('maintenance');
114
+        $this->config->setSystemValue('maintenance', true);
115 115
 
116
-		$this->progress = new ProgressBar($output);
117
-		$this->output = $output;
118
-		$this->dispatcher->addListener('\OC\Repair::startProgress', [$this, 'handleRepairFeedBack']);
119
-		$this->dispatcher->addListener('\OC\Repair::advance', [$this, 'handleRepairFeedBack']);
120
-		$this->dispatcher->addListener('\OC\Repair::finishProgress', [$this, 'handleRepairFeedBack']);
121
-		$this->dispatcher->addListener('\OC\Repair::step', [$this, 'handleRepairFeedBack']);
122
-		$this->dispatcher->addListener('\OC\Repair::info', [$this, 'handleRepairFeedBack']);
123
-		$this->dispatcher->addListener('\OC\Repair::warning', [$this, 'handleRepairFeedBack']);
124
-		$this->dispatcher->addListener('\OC\Repair::error', [$this, 'handleRepairFeedBack']);
116
+        $this->progress = new ProgressBar($output);
117
+        $this->output = $output;
118
+        $this->dispatcher->addListener('\OC\Repair::startProgress', [$this, 'handleRepairFeedBack']);
119
+        $this->dispatcher->addListener('\OC\Repair::advance', [$this, 'handleRepairFeedBack']);
120
+        $this->dispatcher->addListener('\OC\Repair::finishProgress', [$this, 'handleRepairFeedBack']);
121
+        $this->dispatcher->addListener('\OC\Repair::step', [$this, 'handleRepairFeedBack']);
122
+        $this->dispatcher->addListener('\OC\Repair::info', [$this, 'handleRepairFeedBack']);
123
+        $this->dispatcher->addListener('\OC\Repair::warning', [$this, 'handleRepairFeedBack']);
124
+        $this->dispatcher->addListener('\OC\Repair::error', [$this, 'handleRepairFeedBack']);
125 125
 
126
-		$this->repair->run();
126
+        $this->repair->run();
127 127
 
128
-		$this->config->setSystemValue('maintenance', $maintenanceMode);
129
-		return 0;
130
-	}
128
+        $this->config->setSystemValue('maintenance', $maintenanceMode);
129
+        return 0;
130
+    }
131 131
 
132
-	public function handleRepairFeedBack($event) {
133
-		if (!$event instanceof GenericEvent) {
134
-			return;
135
-		}
136
-		switch ($event->getSubject()) {
137
-			case '\OC\Repair::startProgress':
138
-				$this->progress->start($event->getArgument(0));
139
-				break;
140
-			case '\OC\Repair::advance':
141
-				$this->progress->advance($event->getArgument(0));
142
-				break;
143
-			case '\OC\Repair::finishProgress':
144
-				$this->progress->finish();
145
-				$this->output->writeln('');
146
-				break;
147
-			case '\OC\Repair::step':
148
-				$this->output->writeln(' - ' . $event->getArgument(0));
149
-				break;
150
-			case '\OC\Repair::info':
151
-				$this->output->writeln('     - ' . $event->getArgument(0));
152
-				break;
153
-			case '\OC\Repair::warning':
154
-				$this->output->writeln('     - WARNING: ' . $event->getArgument(0));
155
-				break;
156
-			case '\OC\Repair::error':
157
-				$this->output->writeln('     - ERROR: ' . $event->getArgument(0));
158
-				break;
159
-		}
160
-	}
132
+    public function handleRepairFeedBack($event) {
133
+        if (!$event instanceof GenericEvent) {
134
+            return;
135
+        }
136
+        switch ($event->getSubject()) {
137
+            case '\OC\Repair::startProgress':
138
+                $this->progress->start($event->getArgument(0));
139
+                break;
140
+            case '\OC\Repair::advance':
141
+                $this->progress->advance($event->getArgument(0));
142
+                break;
143
+            case '\OC\Repair::finishProgress':
144
+                $this->progress->finish();
145
+                $this->output->writeln('');
146
+                break;
147
+            case '\OC\Repair::step':
148
+                $this->output->writeln(' - ' . $event->getArgument(0));
149
+                break;
150
+            case '\OC\Repair::info':
151
+                $this->output->writeln('     - ' . $event->getArgument(0));
152
+                break;
153
+            case '\OC\Repair::warning':
154
+                $this->output->writeln('     - WARNING: ' . $event->getArgument(0));
155
+                break;
156
+            case '\OC\Repair::error':
157
+                $this->output->writeln('     - ERROR: ' . $event->getArgument(0));
158
+                break;
159
+        }
160
+    }
161 161
 }
Please login to merge, or discard this patch.
core/Command/Maintenance/UpdateTheme.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -34,34 +34,34 @@
 block discarded – undo
34 34
 
35 35
 class UpdateTheme extends UpdateJS {
36 36
 
37
-	/** @var IMimeTypeDetector */
38
-	protected $mimetypeDetector;
37
+    /** @var IMimeTypeDetector */
38
+    protected $mimetypeDetector;
39 39
 
40
-	/** @var ICacheFactory */
41
-	protected $cacheFactory;
40
+    /** @var ICacheFactory */
41
+    protected $cacheFactory;
42 42
 
43
-	public function __construct(
44
-		IMimeTypeDetector $mimetypeDetector,
45
-		ICacheFactory $cacheFactory
46
-	) {
47
-		parent::__construct($mimetypeDetector);
48
-		$this->cacheFactory = $cacheFactory;
49
-	}
43
+    public function __construct(
44
+        IMimeTypeDetector $mimetypeDetector,
45
+        ICacheFactory $cacheFactory
46
+    ) {
47
+        parent::__construct($mimetypeDetector);
48
+        $this->cacheFactory = $cacheFactory;
49
+    }
50 50
 
51
-	protected function configure() {
52
-		$this
53
-			->setName('maintenance:theme:update')
54
-			->setDescription('Apply custom theme changes');
55
-	}
51
+    protected function configure() {
52
+        $this
53
+            ->setName('maintenance:theme:update')
54
+            ->setDescription('Apply custom theme changes');
55
+    }
56 56
 
57
-	protected function execute(InputInterface $input, OutputInterface $output): int {
58
-		// run mimetypelist.js update since themes might change mimetype icons
59
-		parent::execute($input, $output);
57
+    protected function execute(InputInterface $input, OutputInterface $output): int {
58
+        // run mimetypelist.js update since themes might change mimetype icons
59
+        parent::execute($input, $output);
60 60
 
61
-		// cleanup image cache
62
-		$c = $this->cacheFactory->createDistributed('imagePath');
63
-		$c->clear('');
64
-		$output->writeln('<info>Image cache cleared</info>');
65
-		return 0;
66
-	}
61
+        // cleanup image cache
62
+        $c = $this->cacheFactory->createDistributed('imagePath');
63
+        $c->clear('');
64
+        $output->writeln('<info>Image cache cleared</info>');
65
+        return 0;
66
+    }
67 67
 }
Please login to merge, or discard this patch.