@@ -26,53 +26,53 @@ |
||
| 26 | 26 | |
| 27 | 27 | abstract class Base extends \OC\Core\Command\Base { |
| 28 | 28 | |
| 29 | - /** @var SystemConfig */ |
|
| 30 | - protected $systemConfig; |
|
| 29 | + /** @var SystemConfig */ |
|
| 30 | + protected $systemConfig; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @param string $argumentName |
|
| 34 | - * @param CompletionContext $context |
|
| 35 | - * @return string[] |
|
| 36 | - */ |
|
| 37 | - public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
| 38 | - if ($argumentName === 'name') { |
|
| 39 | - $words = $this->getPreviousNames($context, $context->getWordIndex()); |
|
| 40 | - if (empty($words)) { |
|
| 41 | - $completions = $this->systemConfig->getKeys(); |
|
| 42 | - } else { |
|
| 43 | - $key = array_shift($words); |
|
| 44 | - $value = $this->systemConfig->getValue($key); |
|
| 45 | - $completions = array_keys($value); |
|
| 32 | + /** |
|
| 33 | + * @param string $argumentName |
|
| 34 | + * @param CompletionContext $context |
|
| 35 | + * @return string[] |
|
| 36 | + */ |
|
| 37 | + public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
| 38 | + if ($argumentName === 'name') { |
|
| 39 | + $words = $this->getPreviousNames($context, $context->getWordIndex()); |
|
| 40 | + if (empty($words)) { |
|
| 41 | + $completions = $this->systemConfig->getKeys(); |
|
| 42 | + } else { |
|
| 43 | + $key = array_shift($words); |
|
| 44 | + $value = $this->systemConfig->getValue($key); |
|
| 45 | + $completions = array_keys($value); |
|
| 46 | 46 | |
| 47 | - while (!empty($words) && is_array($value)) { |
|
| 48 | - $key = array_shift($words); |
|
| 49 | - if (!isset($value[$key]) || !is_array($value[$key])) { |
|
| 50 | - break; |
|
| 51 | - } |
|
| 47 | + while (!empty($words) && is_array($value)) { |
|
| 48 | + $key = array_shift($words); |
|
| 49 | + if (!isset($value[$key]) || !is_array($value[$key])) { |
|
| 50 | + break; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - $value = $value[$key]; |
|
| 54 | - $completions = array_keys($value); |
|
| 55 | - } |
|
| 56 | - } |
|
| 53 | + $value = $value[$key]; |
|
| 54 | + $completions = array_keys($value); |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - return $completions; |
|
| 59 | - } |
|
| 60 | - return parent::completeArgumentValues($argumentName, $context); |
|
| 61 | - } |
|
| 58 | + return $completions; |
|
| 59 | + } |
|
| 60 | + return parent::completeArgumentValues($argumentName, $context); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * @param CompletionContext $context |
|
| 65 | - * @param int $currentIndex |
|
| 66 | - * @return string[] |
|
| 67 | - */ |
|
| 68 | - protected function getPreviousNames(CompletionContext $context, $currentIndex) { |
|
| 69 | - $word = $context->getWordAtIndex($currentIndex - 1); |
|
| 70 | - if ($word === $this->getName() || $currentIndex <= 0) { |
|
| 71 | - return []; |
|
| 72 | - } |
|
| 63 | + /** |
|
| 64 | + * @param CompletionContext $context |
|
| 65 | + * @param int $currentIndex |
|
| 66 | + * @return string[] |
|
| 67 | + */ |
|
| 68 | + protected function getPreviousNames(CompletionContext $context, $currentIndex) { |
|
| 69 | + $word = $context->getWordAtIndex($currentIndex - 1); |
|
| 70 | + if ($word === $this->getName() || $currentIndex <= 0) { |
|
| 71 | + return []; |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - $words = $this->getPreviousNames($context, $currentIndex - 1); |
|
| 75 | - $words[] = $word; |
|
| 76 | - return $words; |
|
| 77 | - } |
|
| 74 | + $words = $this->getPreviousNames($context, $currentIndex - 1); |
|
| 75 | + $words[] = $word; |
|
| 76 | + return $words; |
|
| 77 | + } |
|
| 78 | 78 | } |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | $this->systemConfig->setValue($configName, $configValue['value']); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - $output->writeln('<info>System config value ' . implode(' => ', $configNames) . ' set to ' . $configValue['readable-value'] . '</info>'); |
|
| 100 | + $output->writeln('<info>System config value '.implode(' => ', $configNames).' set to '.$configValue['readable-value'].'</info>'); |
|
| 101 | 101 | return 0; |
| 102 | 102 | } |
| 103 | 103 | |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | } |
| 117 | 117 | return [ |
| 118 | 118 | 'value' => (int) $value, |
| 119 | - 'readable-value' => 'integer ' . (int) $value, |
|
| 119 | + 'readable-value' => 'integer '.(int) $value, |
|
| 120 | 120 | ]; |
| 121 | 121 | |
| 122 | 122 | case 'double': |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | } |
| 127 | 127 | return [ |
| 128 | 128 | 'value' => (double) $value, |
| 129 | - 'readable-value' => 'double ' . (double) $value, |
|
| 129 | + 'readable-value' => 'double '.(double) $value, |
|
| 130 | 130 | ]; |
| 131 | 131 | |
| 132 | 132 | case 'boolean': |
@@ -136,13 +136,13 @@ discard block |
||
| 136 | 136 | case 'true': |
| 137 | 137 | return [ |
| 138 | 138 | 'value' => true, |
| 139 | - 'readable-value' => 'boolean ' . $value, |
|
| 139 | + 'readable-value' => 'boolean '.$value, |
|
| 140 | 140 | ]; |
| 141 | 141 | |
| 142 | 142 | case 'false': |
| 143 | 143 | return [ |
| 144 | 144 | 'value' => false, |
| 145 | - 'readable-value' => 'boolean ' . $value, |
|
| 145 | + 'readable-value' => 'boolean '.$value, |
|
| 146 | 146 | ]; |
| 147 | 147 | |
| 148 | 148 | default: |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | $value = (string) $value; |
| 160 | 160 | return [ |
| 161 | 161 | 'value' => $value, |
| 162 | - 'readable-value' => ($value === '') ? 'empty string' : 'string ' . $value, |
|
| 162 | + 'readable-value' => ($value === '') ? 'empty string' : 'string '.$value, |
|
| 163 | 163 | ]; |
| 164 | 164 | |
| 165 | 165 | default: |
@@ -33,181 +33,181 @@ |
||
| 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 | } |
@@ -70,12 +70,12 @@ |
||
| 70 | 70 | $configName = $input->getArgument('name'); |
| 71 | 71 | |
| 72 | 72 | if ($input->hasParameterOption('--error-if-not-exists') && !in_array($configName, $this->config->getAppKeys($appName))) { |
| 73 | - $output->writeln('<error>Config ' . $configName . ' of app ' . $appName . ' could not be deleted because it did not exist</error>'); |
|
| 73 | + $output->writeln('<error>Config '.$configName.' of app '.$appName.' could not be deleted because it did not exist</error>'); |
|
| 74 | 74 | return 1; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | $this->config->deleteAppValue($appName, $configName); |
| 78 | - $output->writeln('<info>Config value ' . $configName . ' of app ' . $appName . ' deleted</info>'); |
|
| 78 | + $output->writeln('<info>Config value '.$configName.' of app '.$appName.' deleted</info>'); |
|
| 79 | 79 | return 0; |
| 80 | 80 | } |
| 81 | 81 | } |
@@ -29,53 +29,53 @@ |
||
| 29 | 29 | use Symfony\Component\Console\Output\OutputInterface; |
| 30 | 30 | |
| 31 | 31 | class DeleteConfig extends Base { |
| 32 | - /** * @var IConfig */ |
|
| 33 | - protected $config; |
|
| 32 | + /** * @var IConfig */ |
|
| 33 | + protected $config; |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @param IConfig $config |
|
| 37 | - */ |
|
| 38 | - public function __construct(IConfig $config) { |
|
| 39 | - parent::__construct(); |
|
| 40 | - $this->config = $config; |
|
| 41 | - } |
|
| 35 | + /** |
|
| 36 | + * @param IConfig $config |
|
| 37 | + */ |
|
| 38 | + public function __construct(IConfig $config) { |
|
| 39 | + parent::__construct(); |
|
| 40 | + $this->config = $config; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - protected function configure() { |
|
| 44 | - parent::configure(); |
|
| 43 | + protected function configure() { |
|
| 44 | + parent::configure(); |
|
| 45 | 45 | |
| 46 | - $this |
|
| 47 | - ->setName('config:app:delete') |
|
| 48 | - ->setDescription('Delete an app config value') |
|
| 49 | - ->addArgument( |
|
| 50 | - 'app', |
|
| 51 | - InputArgument::REQUIRED, |
|
| 52 | - 'Name of the app' |
|
| 53 | - ) |
|
| 54 | - ->addArgument( |
|
| 55 | - 'name', |
|
| 56 | - InputArgument::REQUIRED, |
|
| 57 | - 'Name of the config to delete' |
|
| 58 | - ) |
|
| 59 | - ->addOption( |
|
| 60 | - 'error-if-not-exists', |
|
| 61 | - null, |
|
| 62 | - InputOption::VALUE_NONE, |
|
| 63 | - 'Checks whether the config exists before deleting it' |
|
| 64 | - ) |
|
| 65 | - ; |
|
| 66 | - } |
|
| 46 | + $this |
|
| 47 | + ->setName('config:app:delete') |
|
| 48 | + ->setDescription('Delete an app config value') |
|
| 49 | + ->addArgument( |
|
| 50 | + 'app', |
|
| 51 | + InputArgument::REQUIRED, |
|
| 52 | + 'Name of the app' |
|
| 53 | + ) |
|
| 54 | + ->addArgument( |
|
| 55 | + 'name', |
|
| 56 | + InputArgument::REQUIRED, |
|
| 57 | + 'Name of the config to delete' |
|
| 58 | + ) |
|
| 59 | + ->addOption( |
|
| 60 | + 'error-if-not-exists', |
|
| 61 | + null, |
|
| 62 | + InputOption::VALUE_NONE, |
|
| 63 | + 'Checks whether the config exists before deleting it' |
|
| 64 | + ) |
|
| 65 | + ; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
| 69 | - $appName = $input->getArgument('app'); |
|
| 70 | - $configName = $input->getArgument('name'); |
|
| 68 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
| 69 | + $appName = $input->getArgument('app'); |
|
| 70 | + $configName = $input->getArgument('name'); |
|
| 71 | 71 | |
| 72 | - if ($input->hasParameterOption('--error-if-not-exists') && !in_array($configName, $this->config->getAppKeys($appName))) { |
|
| 73 | - $output->writeln('<error>Config ' . $configName . ' of app ' . $appName . ' could not be deleted because it did not exist</error>'); |
|
| 74 | - return 1; |
|
| 75 | - } |
|
| 72 | + if ($input->hasParameterOption('--error-if-not-exists') && !in_array($configName, $this->config->getAppKeys($appName))) { |
|
| 73 | + $output->writeln('<error>Config ' . $configName . ' of app ' . $appName . ' could not be deleted because it did not exist</error>'); |
|
| 74 | + return 1; |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - $this->config->deleteAppValue($appName, $configName); |
|
| 78 | - $output->writeln('<info>Config value ' . $configName . ' of app ' . $appName . ' deleted</info>'); |
|
| 79 | - return 0; |
|
| 80 | - } |
|
| 77 | + $this->config->deleteAppValue($appName, $configName); |
|
| 78 | + $output->writeln('<info>Config value ' . $configName . ' of app ' . $appName . ' deleted</info>'); |
|
| 79 | + return 0; |
|
| 80 | + } |
|
| 81 | 81 | } |
@@ -26,23 +26,23 @@ |
||
| 26 | 26 | |
| 27 | 27 | abstract class Base extends \OC\Core\Command\Base { |
| 28 | 28 | |
| 29 | - /** * @var IConfig */ |
|
| 30 | - protected $config; |
|
| 29 | + /** * @var IConfig */ |
|
| 30 | + protected $config; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @param string $argumentName |
|
| 34 | - * @param CompletionContext $context |
|
| 35 | - * @return string[] |
|
| 36 | - */ |
|
| 37 | - public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
| 38 | - if ($argumentName === 'app') { |
|
| 39 | - return \OC_App::getAllApps(); |
|
| 40 | - } |
|
| 32 | + /** |
|
| 33 | + * @param string $argumentName |
|
| 34 | + * @param CompletionContext $context |
|
| 35 | + * @return string[] |
|
| 36 | + */ |
|
| 37 | + public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
| 38 | + if ($argumentName === 'app') { |
|
| 39 | + return \OC_App::getAllApps(); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - if ($argumentName === 'name') { |
|
| 43 | - $appName = $context->getWordAtIndex($context->getWordIndex() - 1); |
|
| 44 | - return $this->config->getAppKeys($appName); |
|
| 45 | - } |
|
| 46 | - return []; |
|
| 47 | - } |
|
| 42 | + if ($argumentName === 'name') { |
|
| 43 | + $appName = $context->getWordAtIndex($context->getWordIndex() - 1); |
|
| 44 | + return $this->config->getAppKeys($appName); |
|
| 45 | + } |
|
| 46 | + return []; |
|
| 47 | + } |
|
| 48 | 48 | } |
@@ -76,14 +76,14 @@ |
||
| 76 | 76 | $configName = $input->getArgument('name'); |
| 77 | 77 | |
| 78 | 78 | if (!in_array($configName, $this->config->getAppKeys($appName)) && $input->hasParameterOption('--update-only')) { |
| 79 | - $output->writeln('<comment>Config value ' . $configName . ' for app ' . $appName . ' not updated, as it has not been set before.</comment>'); |
|
| 79 | + $output->writeln('<comment>Config value '.$configName.' for app '.$appName.' not updated, as it has not been set before.</comment>'); |
|
| 80 | 80 | return 1; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | $configValue = $input->getOption('value'); |
| 84 | 84 | $this->config->setAppValue($appName, $configName, $configValue); |
| 85 | 85 | |
| 86 | - $output->writeln('<info>Config value ' . $configName . ' for app ' . $appName . ' set to ' . $configValue . '</info>'); |
|
| 86 | + $output->writeln('<info>Config value '.$configName.' for app '.$appName.' set to '.$configValue.'</info>'); |
|
| 87 | 87 | return 0; |
| 88 | 88 | } |
| 89 | 89 | } |
@@ -29,61 +29,61 @@ |
||
| 29 | 29 | use Symfony\Component\Console\Output\OutputInterface; |
| 30 | 30 | |
| 31 | 31 | class SetConfig extends Base { |
| 32 | - /** * @var IConfig */ |
|
| 33 | - protected $config; |
|
| 32 | + /** * @var IConfig */ |
|
| 33 | + protected $config; |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @param IConfig $config |
|
| 37 | - */ |
|
| 38 | - public function __construct(IConfig $config) { |
|
| 39 | - parent::__construct(); |
|
| 40 | - $this->config = $config; |
|
| 41 | - } |
|
| 35 | + /** |
|
| 36 | + * @param IConfig $config |
|
| 37 | + */ |
|
| 38 | + public function __construct(IConfig $config) { |
|
| 39 | + parent::__construct(); |
|
| 40 | + $this->config = $config; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - protected function configure() { |
|
| 44 | - parent::configure(); |
|
| 43 | + protected function configure() { |
|
| 44 | + parent::configure(); |
|
| 45 | 45 | |
| 46 | - $this |
|
| 47 | - ->setName('config:app:set') |
|
| 48 | - ->setDescription('Set an app config value') |
|
| 49 | - ->addArgument( |
|
| 50 | - 'app', |
|
| 51 | - InputArgument::REQUIRED, |
|
| 52 | - 'Name of the app' |
|
| 53 | - ) |
|
| 54 | - ->addArgument( |
|
| 55 | - 'name', |
|
| 56 | - InputArgument::REQUIRED, |
|
| 57 | - 'Name of the config to set' |
|
| 58 | - ) |
|
| 59 | - ->addOption( |
|
| 60 | - 'value', |
|
| 61 | - null, |
|
| 62 | - InputOption::VALUE_REQUIRED, |
|
| 63 | - 'The new value of the config' |
|
| 64 | - ) |
|
| 65 | - ->addOption( |
|
| 66 | - 'update-only', |
|
| 67 | - null, |
|
| 68 | - InputOption::VALUE_NONE, |
|
| 69 | - 'Only updates the value, if it is not set before, it is not being added' |
|
| 70 | - ) |
|
| 71 | - ; |
|
| 72 | - } |
|
| 46 | + $this |
|
| 47 | + ->setName('config:app:set') |
|
| 48 | + ->setDescription('Set an app config value') |
|
| 49 | + ->addArgument( |
|
| 50 | + 'app', |
|
| 51 | + InputArgument::REQUIRED, |
|
| 52 | + 'Name of the app' |
|
| 53 | + ) |
|
| 54 | + ->addArgument( |
|
| 55 | + 'name', |
|
| 56 | + InputArgument::REQUIRED, |
|
| 57 | + 'Name of the config to set' |
|
| 58 | + ) |
|
| 59 | + ->addOption( |
|
| 60 | + 'value', |
|
| 61 | + null, |
|
| 62 | + InputOption::VALUE_REQUIRED, |
|
| 63 | + 'The new value of the config' |
|
| 64 | + ) |
|
| 65 | + ->addOption( |
|
| 66 | + 'update-only', |
|
| 67 | + null, |
|
| 68 | + InputOption::VALUE_NONE, |
|
| 69 | + 'Only updates the value, if it is not set before, it is not being added' |
|
| 70 | + ) |
|
| 71 | + ; |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
| 75 | - $appName = $input->getArgument('app'); |
|
| 76 | - $configName = $input->getArgument('name'); |
|
| 74 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
| 75 | + $appName = $input->getArgument('app'); |
|
| 76 | + $configName = $input->getArgument('name'); |
|
| 77 | 77 | |
| 78 | - if (!in_array($configName, $this->config->getAppKeys($appName)) && $input->hasParameterOption('--update-only')) { |
|
| 79 | - $output->writeln('<comment>Config value ' . $configName . ' for app ' . $appName . ' not updated, as it has not been set before.</comment>'); |
|
| 80 | - return 1; |
|
| 81 | - } |
|
| 78 | + if (!in_array($configName, $this->config->getAppKeys($appName)) && $input->hasParameterOption('--update-only')) { |
|
| 79 | + $output->writeln('<comment>Config value ' . $configName . ' for app ' . $appName . ' not updated, as it has not been set before.</comment>'); |
|
| 80 | + return 1; |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - $configValue = $input->getOption('value'); |
|
| 84 | - $this->config->setAppValue($appName, $configName, $configValue); |
|
| 83 | + $configValue = $input->getOption('value'); |
|
| 84 | + $this->config->setAppValue($appName, $configName, $configValue); |
|
| 85 | 85 | |
| 86 | - $output->writeln('<info>Config value ' . $configName . ' for app ' . $appName . ' set to ' . $configValue . '</info>'); |
|
| 87 | - return 0; |
|
| 88 | - } |
|
| 86 | + $output->writeln('<info>Config value ' . $configName . ' for app ' . $appName . ' set to ' . $configValue . '</info>'); |
|
| 87 | + return 0; |
|
| 88 | + } |
|
| 89 | 89 | } |
@@ -132,16 +132,16 @@ |
||
| 132 | 132 | $this->output->writeln(''); |
| 133 | 133 | break; |
| 134 | 134 | case '\OC\Repair::step': |
| 135 | - $this->output->writeln(' - ' . $event->getArgument(0)); |
|
| 135 | + $this->output->writeln(' - '.$event->getArgument(0)); |
|
| 136 | 136 | break; |
| 137 | 137 | case '\OC\Repair::info': |
| 138 | - $this->output->writeln(' - ' . $event->getArgument(0)); |
|
| 138 | + $this->output->writeln(' - '.$event->getArgument(0)); |
|
| 139 | 139 | break; |
| 140 | 140 | case '\OC\Repair::warning': |
| 141 | - $this->output->writeln(' - WARNING: ' . $event->getArgument(0)); |
|
| 141 | + $this->output->writeln(' - WARNING: '.$event->getArgument(0)); |
|
| 142 | 142 | break; |
| 143 | 143 | case '\OC\Repair::error': |
| 144 | - $this->output->writeln(' - ERROR: ' . $event->getArgument(0)); |
|
| 144 | + $this->output->writeln(' - ERROR: '.$event->getArgument(0)); |
|
| 145 | 145 | break; |
| 146 | 146 | } |
| 147 | 147 | } |
@@ -41,121 +41,121 @@ |
||
| 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 | } |
@@ -68,7 +68,7 @@ |
||
| 68 | 68 | try { |
| 69 | 69 | $mount = $this->globalService->getStorage($mountId); |
| 70 | 70 | } catch (NotFoundException $e) { |
| 71 | - $output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts"</error>'); |
|
| 71 | + $output->writeln('<error>Mount with id "'.$mountId.' not found, check "occ files_external:list" to get available mounts"</error>'); |
|
| 72 | 72 | return 404; |
| 73 | 73 | } |
| 74 | 74 | |
@@ -39,77 +39,77 @@ |
||
| 39 | 39 | use Symfony\Component\Console\Question\ConfirmationQuestion; |
| 40 | 40 | |
| 41 | 41 | class Delete extends Base { |
| 42 | - /** |
|
| 43 | - * @var GlobalStoragesService |
|
| 44 | - */ |
|
| 45 | - protected $globalService; |
|
| 42 | + /** |
|
| 43 | + * @var GlobalStoragesService |
|
| 44 | + */ |
|
| 45 | + protected $globalService; |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * @var UserStoragesService |
|
| 49 | - */ |
|
| 50 | - protected $userService; |
|
| 47 | + /** |
|
| 48 | + * @var UserStoragesService |
|
| 49 | + */ |
|
| 50 | + protected $userService; |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * @var IUserSession |
|
| 54 | - */ |
|
| 55 | - protected $userSession; |
|
| 52 | + /** |
|
| 53 | + * @var IUserSession |
|
| 54 | + */ |
|
| 55 | + protected $userSession; |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * @var IUserManager |
|
| 59 | - */ |
|
| 60 | - protected $userManager; |
|
| 57 | + /** |
|
| 58 | + * @var IUserManager |
|
| 59 | + */ |
|
| 60 | + protected $userManager; |
|
| 61 | 61 | |
| 62 | - public function __construct(GlobalStoragesService $globalService, UserStoragesService $userService, IUserSession $userSession, IUserManager $userManager) { |
|
| 63 | - parent::__construct(); |
|
| 64 | - $this->globalService = $globalService; |
|
| 65 | - $this->userService = $userService; |
|
| 66 | - $this->userSession = $userSession; |
|
| 67 | - $this->userManager = $userManager; |
|
| 68 | - } |
|
| 62 | + public function __construct(GlobalStoragesService $globalService, UserStoragesService $userService, IUserSession $userSession, IUserManager $userManager) { |
|
| 63 | + parent::__construct(); |
|
| 64 | + $this->globalService = $globalService; |
|
| 65 | + $this->userService = $userService; |
|
| 66 | + $this->userSession = $userSession; |
|
| 67 | + $this->userManager = $userManager; |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - protected function configure() { |
|
| 71 | - $this |
|
| 72 | - ->setName('files_external:delete') |
|
| 73 | - ->setDescription('Delete an external mount') |
|
| 74 | - ->addArgument( |
|
| 75 | - 'mount_id', |
|
| 76 | - InputArgument::REQUIRED, |
|
| 77 | - 'The id of the mount to edit' |
|
| 78 | - )->addOption( |
|
| 79 | - 'yes', |
|
| 80 | - 'y', |
|
| 81 | - InputOption::VALUE_NONE, |
|
| 82 | - 'Skip confirmation' |
|
| 83 | - ); |
|
| 84 | - parent::configure(); |
|
| 85 | - } |
|
| 70 | + protected function configure() { |
|
| 71 | + $this |
|
| 72 | + ->setName('files_external:delete') |
|
| 73 | + ->setDescription('Delete an external mount') |
|
| 74 | + ->addArgument( |
|
| 75 | + 'mount_id', |
|
| 76 | + InputArgument::REQUIRED, |
|
| 77 | + 'The id of the mount to edit' |
|
| 78 | + )->addOption( |
|
| 79 | + 'yes', |
|
| 80 | + 'y', |
|
| 81 | + InputOption::VALUE_NONE, |
|
| 82 | + 'Skip confirmation' |
|
| 83 | + ); |
|
| 84 | + parent::configure(); |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
| 88 | - $mountId = $input->getArgument('mount_id'); |
|
| 89 | - try { |
|
| 90 | - $mount = $this->globalService->getStorage($mountId); |
|
| 91 | - } catch (NotFoundException $e) { |
|
| 92 | - $output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts"</error>'); |
|
| 93 | - return 404; |
|
| 94 | - } |
|
| 87 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
| 88 | + $mountId = $input->getArgument('mount_id'); |
|
| 89 | + try { |
|
| 90 | + $mount = $this->globalService->getStorage($mountId); |
|
| 91 | + } catch (NotFoundException $e) { |
|
| 92 | + $output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts"</error>'); |
|
| 93 | + return 404; |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - $noConfirm = $input->getOption('yes'); |
|
| 96 | + $noConfirm = $input->getOption('yes'); |
|
| 97 | 97 | |
| 98 | - if (!$noConfirm) { |
|
| 99 | - $listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager); |
|
| 100 | - $listInput = new ArrayInput([], $listCommand->getDefinition()); |
|
| 101 | - $listInput->setOption('output', $input->getOption('output')); |
|
| 102 | - $listCommand->listMounts(null, [$mount], $listInput, $output); |
|
| 98 | + if (!$noConfirm) { |
|
| 99 | + $listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager); |
|
| 100 | + $listInput = new ArrayInput([], $listCommand->getDefinition()); |
|
| 101 | + $listInput->setOption('output', $input->getOption('output')); |
|
| 102 | + $listCommand->listMounts(null, [$mount], $listInput, $output); |
|
| 103 | 103 | |
| 104 | - $questionHelper = $this->getHelper('question'); |
|
| 105 | - $question = new ConfirmationQuestion('Delete this mount? [y/N] ', false); |
|
| 104 | + $questionHelper = $this->getHelper('question'); |
|
| 105 | + $question = new ConfirmationQuestion('Delete this mount? [y/N] ', false); |
|
| 106 | 106 | |
| 107 | - if (!$questionHelper->ask($input, $output, $question)) { |
|
| 108 | - return 1; |
|
| 109 | - } |
|
| 110 | - } |
|
| 107 | + if (!$questionHelper->ask($input, $output, $question)) { |
|
| 108 | + return 1; |
|
| 109 | + } |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | - $this->globalService->removeStorage($mountId); |
|
| 113 | - return 0; |
|
| 114 | - } |
|
| 112 | + $this->globalService->removeStorage($mountId); |
|
| 113 | + return 0; |
|
| 114 | + } |
|
| 115 | 115 | } |
@@ -33,33 +33,33 @@ |
||
| 33 | 33 | */ |
| 34 | 34 | interface IAction extends JsonSerializable { |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @param string $icon absolute URI to an icon |
|
| 38 | - * @since 12.0 |
|
| 39 | - */ |
|
| 40 | - public function setIcon($icon); |
|
| 36 | + /** |
|
| 37 | + * @param string $icon absolute URI to an icon |
|
| 38 | + * @since 12.0 |
|
| 39 | + */ |
|
| 40 | + public function setIcon($icon); |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @return string localized action name, e.g. 'Call' |
|
| 44 | - * @since 12.0 |
|
| 45 | - */ |
|
| 46 | - public function getName(); |
|
| 42 | + /** |
|
| 43 | + * @return string localized action name, e.g. 'Call' |
|
| 44 | + * @since 12.0 |
|
| 45 | + */ |
|
| 46 | + public function getName(); |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * @param string $name localized action name, e.g. 'Call' |
|
| 50 | - * @since 12.0 |
|
| 51 | - */ |
|
| 52 | - public function setName($name); |
|
| 48 | + /** |
|
| 49 | + * @param string $name localized action name, e.g. 'Call' |
|
| 50 | + * @since 12.0 |
|
| 51 | + */ |
|
| 52 | + public function setName($name); |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * @param int $priority priorize actions, high order ones are shown on top |
|
| 56 | - * @since 12.0 |
|
| 57 | - */ |
|
| 58 | - public function setPriority($priority); |
|
| 54 | + /** |
|
| 55 | + * @param int $priority priorize actions, high order ones are shown on top |
|
| 56 | + * @since 12.0 |
|
| 57 | + */ |
|
| 58 | + public function setPriority($priority); |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * @return int priority to priorize actions, high order ones are shown on top |
|
| 62 | - * @since 12.0 |
|
| 63 | - */ |
|
| 64 | - public function getPriority(); |
|
| 60 | + /** |
|
| 61 | + * @return int priority to priorize actions, high order ones are shown on top |
|
| 62 | + * @since 12.0 |
|
| 63 | + */ |
|
| 64 | + public function getPriority(); |
|
| 65 | 65 | } |
@@ -28,27 +28,27 @@ |
||
| 28 | 28 | */ |
| 29 | 29 | interface IActionFactory { |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Construct and return a new link action for the contacts menu |
|
| 33 | - * |
|
| 34 | - * @since 12.0 |
|
| 35 | - * |
|
| 36 | - * @param string $icon full path to the action's icon |
|
| 37 | - * @param string $name localized name of the action |
|
| 38 | - * @param string $href target URL |
|
| 39 | - * @return ILinkAction |
|
| 40 | - */ |
|
| 41 | - public function newLinkAction($icon, $name, $href); |
|
| 31 | + /** |
|
| 32 | + * Construct and return a new link action for the contacts menu |
|
| 33 | + * |
|
| 34 | + * @since 12.0 |
|
| 35 | + * |
|
| 36 | + * @param string $icon full path to the action's icon |
|
| 37 | + * @param string $name localized name of the action |
|
| 38 | + * @param string $href target URL |
|
| 39 | + * @return ILinkAction |
|
| 40 | + */ |
|
| 41 | + public function newLinkAction($icon, $name, $href); |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Construct and return a new email action for the contacts menu |
|
| 45 | - * |
|
| 46 | - * @since 12.0 |
|
| 47 | - * |
|
| 48 | - * @param string $icon full path to the action's icon |
|
| 49 | - * @param string $name localized name of the action |
|
| 50 | - * @param string $email target e-mail address |
|
| 51 | - * @return ILinkAction |
|
| 52 | - */ |
|
| 53 | - public function newEMailAction($icon, $name, $email); |
|
| 43 | + /** |
|
| 44 | + * Construct and return a new email action for the contacts menu |
|
| 45 | + * |
|
| 46 | + * @since 12.0 |
|
| 47 | + * |
|
| 48 | + * @param string $icon full path to the action's icon |
|
| 49 | + * @param string $name localized name of the action |
|
| 50 | + * @param string $email target e-mail address |
|
| 51 | + * @return ILinkAction |
|
| 52 | + */ |
|
| 53 | + public function newEMailAction($icon, $name, $email); |
|
| 54 | 54 | } |