@@ -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: |
@@ -32,181 +32,181 @@ |
||
| 32 | 32 | use Symfony\Component\Console\Output\OutputInterface; |
| 33 | 33 | |
| 34 | 34 | class SetConfig extends Base { |
| 35 | - /** * @var SystemConfig */ |
|
| 36 | - protected $systemConfig; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * @param SystemConfig $systemConfig |
|
| 40 | - */ |
|
| 41 | - public function __construct(SystemConfig $systemConfig) { |
|
| 42 | - parent::__construct(); |
|
| 43 | - $this->systemConfig = $systemConfig; |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - protected function configure() { |
|
| 47 | - parent::configure(); |
|
| 48 | - |
|
| 49 | - $this |
|
| 50 | - ->setName('config:system:set') |
|
| 51 | - ->setDescription('Set a system config value') |
|
| 52 | - ->addArgument( |
|
| 53 | - 'name', |
|
| 54 | - InputArgument::REQUIRED | InputArgument::IS_ARRAY, |
|
| 55 | - 'Name of the config parameter, specify multiple for array parameter' |
|
| 56 | - ) |
|
| 57 | - ->addOption( |
|
| 58 | - 'type', |
|
| 59 | - null, |
|
| 60 | - InputOption::VALUE_REQUIRED, |
|
| 61 | - 'Value type [string, integer, double, boolean]', |
|
| 62 | - 'string' |
|
| 63 | - ) |
|
| 64 | - ->addOption( |
|
| 65 | - 'value', |
|
| 66 | - null, |
|
| 67 | - InputOption::VALUE_REQUIRED, |
|
| 68 | - 'The new value of the config' |
|
| 69 | - ) |
|
| 70 | - ->addOption( |
|
| 71 | - 'update-only', |
|
| 72 | - null, |
|
| 73 | - InputOption::VALUE_NONE, |
|
| 74 | - 'Only updates the value, if it is not set before, it is not being added' |
|
| 75 | - ) |
|
| 76 | - ; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 80 | - $configNames = $input->getArgument('name'); |
|
| 81 | - $configName = $configNames[0]; |
|
| 82 | - $configValue = $this->castValue($input->getOption('value'), $input->getOption('type')); |
|
| 83 | - $updateOnly = $input->getOption('update-only'); |
|
| 84 | - |
|
| 85 | - if (count($configNames) > 1) { |
|
| 86 | - $existingValue = $this->systemConfig->getValue($configName); |
|
| 87 | - |
|
| 88 | - $newValue = $this->mergeArrayValue( |
|
| 89 | - array_slice($configNames, 1), $existingValue, $configValue['value'], $updateOnly |
|
| 90 | - ); |
|
| 91 | - |
|
| 92 | - $this->systemConfig->setValue($configName, $newValue); |
|
| 93 | - } else { |
|
| 94 | - if ($updateOnly && !in_array($configName, $this->systemConfig->getKeys(), true)) { |
|
| 95 | - throw new \UnexpectedValueException('Config parameter does not exist'); |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - $this->systemConfig->setValue($configName, $configValue['value']); |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - $output->writeln('<info>System config value ' . implode(' => ', $configNames) . ' set to ' . $configValue['readable-value'] . '</info>'); |
|
| 102 | - return 0; |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * @param string $value |
|
| 107 | - * @param string $type |
|
| 108 | - * @return mixed |
|
| 109 | - * @throws \InvalidArgumentException |
|
| 110 | - */ |
|
| 111 | - protected function castValue($value, $type) { |
|
| 112 | - switch ($type) { |
|
| 113 | - case 'integer': |
|
| 114 | - case 'int': |
|
| 115 | - if (!is_numeric($value)) { |
|
| 116 | - throw new \InvalidArgumentException('Non-numeric value specified'); |
|
| 117 | - } |
|
| 118 | - return [ |
|
| 119 | - 'value' => (int) $value, |
|
| 120 | - 'readable-value' => 'integer ' . (int) $value, |
|
| 121 | - ]; |
|
| 122 | - |
|
| 123 | - case 'double': |
|
| 124 | - case 'float': |
|
| 125 | - if (!is_numeric($value)) { |
|
| 126 | - throw new \InvalidArgumentException('Non-numeric value specified'); |
|
| 127 | - } |
|
| 128 | - return [ |
|
| 129 | - 'value' => (double) $value, |
|
| 130 | - 'readable-value' => 'double ' . (double) $value, |
|
| 131 | - ]; |
|
| 132 | - |
|
| 133 | - case 'boolean': |
|
| 134 | - case 'bool': |
|
| 135 | - $value = strtolower($value); |
|
| 136 | - switch ($value) { |
|
| 137 | - case 'true': |
|
| 138 | - return [ |
|
| 139 | - 'value' => true, |
|
| 140 | - 'readable-value' => 'boolean ' . $value, |
|
| 141 | - ]; |
|
| 142 | - |
|
| 143 | - case 'false': |
|
| 144 | - return [ |
|
| 145 | - 'value' => false, |
|
| 146 | - 'readable-value' => 'boolean ' . $value, |
|
| 147 | - ]; |
|
| 148 | - |
|
| 149 | - default: |
|
| 150 | - throw new \InvalidArgumentException('Unable to parse value as boolean'); |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - // no break |
|
| 154 | - case 'null': |
|
| 155 | - return [ |
|
| 156 | - 'value' => null, |
|
| 157 | - 'readable-value' => 'null', |
|
| 158 | - ]; |
|
| 159 | - |
|
| 160 | - case 'string': |
|
| 161 | - $value = (string) $value; |
|
| 162 | - return [ |
|
| 163 | - 'value' => $value, |
|
| 164 | - 'readable-value' => ($value === '') ? 'empty string' : 'string ' . $value, |
|
| 165 | - ]; |
|
| 166 | - |
|
| 167 | - default: |
|
| 168 | - throw new \InvalidArgumentException('Invalid type'); |
|
| 169 | - } |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - /** |
|
| 173 | - * @param array $configNames |
|
| 174 | - * @param mixed $existingValues |
|
| 175 | - * @param mixed $value |
|
| 176 | - * @param bool $updateOnly |
|
| 177 | - * @return array merged value |
|
| 178 | - * @throws \UnexpectedValueException |
|
| 179 | - */ |
|
| 180 | - protected function mergeArrayValue(array $configNames, $existingValues, $value, $updateOnly) { |
|
| 181 | - $configName = array_shift($configNames); |
|
| 182 | - if (!is_array($existingValues)) { |
|
| 183 | - $existingValues = []; |
|
| 184 | - } |
|
| 185 | - if (!empty($configNames)) { |
|
| 186 | - if (isset($existingValues[$configName])) { |
|
| 187 | - $existingValue = $existingValues[$configName]; |
|
| 188 | - } else { |
|
| 189 | - $existingValue = []; |
|
| 190 | - } |
|
| 191 | - $existingValues[$configName] = $this->mergeArrayValue($configNames, $existingValue, $value, $updateOnly); |
|
| 192 | - } else { |
|
| 193 | - if (!isset($existingValues[$configName]) && $updateOnly) { |
|
| 194 | - throw new \UnexpectedValueException('Config parameter does not exist'); |
|
| 195 | - } |
|
| 196 | - $existingValues[$configName] = $value; |
|
| 197 | - } |
|
| 198 | - return $existingValues; |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - /** |
|
| 202 | - * @param string $optionName |
|
| 203 | - * @param CompletionContext $context |
|
| 204 | - * @return string[] |
|
| 205 | - */ |
|
| 206 | - public function completeOptionValues($optionName, CompletionContext $context) { |
|
| 207 | - if ($optionName === 'type') { |
|
| 208 | - return ['string', 'integer', 'double', 'boolean']; |
|
| 209 | - } |
|
| 210 | - return parent::completeOptionValues($optionName, $context); |
|
| 211 | - } |
|
| 35 | + /** * @var SystemConfig */ |
|
| 36 | + protected $systemConfig; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * @param SystemConfig $systemConfig |
|
| 40 | + */ |
|
| 41 | + public function __construct(SystemConfig $systemConfig) { |
|
| 42 | + parent::__construct(); |
|
| 43 | + $this->systemConfig = $systemConfig; |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + protected function configure() { |
|
| 47 | + parent::configure(); |
|
| 48 | + |
|
| 49 | + $this |
|
| 50 | + ->setName('config:system:set') |
|
| 51 | + ->setDescription('Set a system config value') |
|
| 52 | + ->addArgument( |
|
| 53 | + 'name', |
|
| 54 | + InputArgument::REQUIRED | InputArgument::IS_ARRAY, |
|
| 55 | + 'Name of the config parameter, specify multiple for array parameter' |
|
| 56 | + ) |
|
| 57 | + ->addOption( |
|
| 58 | + 'type', |
|
| 59 | + null, |
|
| 60 | + InputOption::VALUE_REQUIRED, |
|
| 61 | + 'Value type [string, integer, double, boolean]', |
|
| 62 | + 'string' |
|
| 63 | + ) |
|
| 64 | + ->addOption( |
|
| 65 | + 'value', |
|
| 66 | + null, |
|
| 67 | + InputOption::VALUE_REQUIRED, |
|
| 68 | + 'The new value of the config' |
|
| 69 | + ) |
|
| 70 | + ->addOption( |
|
| 71 | + 'update-only', |
|
| 72 | + null, |
|
| 73 | + InputOption::VALUE_NONE, |
|
| 74 | + 'Only updates the value, if it is not set before, it is not being added' |
|
| 75 | + ) |
|
| 76 | + ; |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 80 | + $configNames = $input->getArgument('name'); |
|
| 81 | + $configName = $configNames[0]; |
|
| 82 | + $configValue = $this->castValue($input->getOption('value'), $input->getOption('type')); |
|
| 83 | + $updateOnly = $input->getOption('update-only'); |
|
| 84 | + |
|
| 85 | + if (count($configNames) > 1) { |
|
| 86 | + $existingValue = $this->systemConfig->getValue($configName); |
|
| 87 | + |
|
| 88 | + $newValue = $this->mergeArrayValue( |
|
| 89 | + array_slice($configNames, 1), $existingValue, $configValue['value'], $updateOnly |
|
| 90 | + ); |
|
| 91 | + |
|
| 92 | + $this->systemConfig->setValue($configName, $newValue); |
|
| 93 | + } else { |
|
| 94 | + if ($updateOnly && !in_array($configName, $this->systemConfig->getKeys(), true)) { |
|
| 95 | + throw new \UnexpectedValueException('Config parameter does not exist'); |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + $this->systemConfig->setValue($configName, $configValue['value']); |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + $output->writeln('<info>System config value ' . implode(' => ', $configNames) . ' set to ' . $configValue['readable-value'] . '</info>'); |
|
| 102 | + return 0; |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * @param string $value |
|
| 107 | + * @param string $type |
|
| 108 | + * @return mixed |
|
| 109 | + * @throws \InvalidArgumentException |
|
| 110 | + */ |
|
| 111 | + protected function castValue($value, $type) { |
|
| 112 | + switch ($type) { |
|
| 113 | + case 'integer': |
|
| 114 | + case 'int': |
|
| 115 | + if (!is_numeric($value)) { |
|
| 116 | + throw new \InvalidArgumentException('Non-numeric value specified'); |
|
| 117 | + } |
|
| 118 | + return [ |
|
| 119 | + 'value' => (int) $value, |
|
| 120 | + 'readable-value' => 'integer ' . (int) $value, |
|
| 121 | + ]; |
|
| 122 | + |
|
| 123 | + case 'double': |
|
| 124 | + case 'float': |
|
| 125 | + if (!is_numeric($value)) { |
|
| 126 | + throw new \InvalidArgumentException('Non-numeric value specified'); |
|
| 127 | + } |
|
| 128 | + return [ |
|
| 129 | + 'value' => (double) $value, |
|
| 130 | + 'readable-value' => 'double ' . (double) $value, |
|
| 131 | + ]; |
|
| 132 | + |
|
| 133 | + case 'boolean': |
|
| 134 | + case 'bool': |
|
| 135 | + $value = strtolower($value); |
|
| 136 | + switch ($value) { |
|
| 137 | + case 'true': |
|
| 138 | + return [ |
|
| 139 | + 'value' => true, |
|
| 140 | + 'readable-value' => 'boolean ' . $value, |
|
| 141 | + ]; |
|
| 142 | + |
|
| 143 | + case 'false': |
|
| 144 | + return [ |
|
| 145 | + 'value' => false, |
|
| 146 | + 'readable-value' => 'boolean ' . $value, |
|
| 147 | + ]; |
|
| 148 | + |
|
| 149 | + default: |
|
| 150 | + throw new \InvalidArgumentException('Unable to parse value as boolean'); |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + // no break |
|
| 154 | + case 'null': |
|
| 155 | + return [ |
|
| 156 | + 'value' => null, |
|
| 157 | + 'readable-value' => 'null', |
|
| 158 | + ]; |
|
| 159 | + |
|
| 160 | + case 'string': |
|
| 161 | + $value = (string) $value; |
|
| 162 | + return [ |
|
| 163 | + 'value' => $value, |
|
| 164 | + 'readable-value' => ($value === '') ? 'empty string' : 'string ' . $value, |
|
| 165 | + ]; |
|
| 166 | + |
|
| 167 | + default: |
|
| 168 | + throw new \InvalidArgumentException('Invalid type'); |
|
| 169 | + } |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + /** |
|
| 173 | + * @param array $configNames |
|
| 174 | + * @param mixed $existingValues |
|
| 175 | + * @param mixed $value |
|
| 176 | + * @param bool $updateOnly |
|
| 177 | + * @return array merged value |
|
| 178 | + * @throws \UnexpectedValueException |
|
| 179 | + */ |
|
| 180 | + protected function mergeArrayValue(array $configNames, $existingValues, $value, $updateOnly) { |
|
| 181 | + $configName = array_shift($configNames); |
|
| 182 | + if (!is_array($existingValues)) { |
|
| 183 | + $existingValues = []; |
|
| 184 | + } |
|
| 185 | + if (!empty($configNames)) { |
|
| 186 | + if (isset($existingValues[$configName])) { |
|
| 187 | + $existingValue = $existingValues[$configName]; |
|
| 188 | + } else { |
|
| 189 | + $existingValue = []; |
|
| 190 | + } |
|
| 191 | + $existingValues[$configName] = $this->mergeArrayValue($configNames, $existingValue, $value, $updateOnly); |
|
| 192 | + } else { |
|
| 193 | + if (!isset($existingValues[$configName]) && $updateOnly) { |
|
| 194 | + throw new \UnexpectedValueException('Config parameter does not exist'); |
|
| 195 | + } |
|
| 196 | + $existingValues[$configName] = $value; |
|
| 197 | + } |
|
| 198 | + return $existingValues; |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + /** |
|
| 202 | + * @param string $optionName |
|
| 203 | + * @param CompletionContext $context |
|
| 204 | + * @return string[] |
|
| 205 | + */ |
|
| 206 | + public function completeOptionValues($optionName, CompletionContext $context) { |
|
| 207 | + if ($optionName === 'type') { |
|
| 208 | + return ['string', 'integer', 'double', 'boolean']; |
|
| 209 | + } |
|
| 210 | + return parent::completeOptionValues($optionName, $context); |
|
| 211 | + } |
|
| 212 | 212 | } |
@@ -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) { |
|
| 69 | - $appName = $input->getArgument('app'); |
|
| 70 | - $configName = $input->getArgument('name'); |
|
| 68 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -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) { |
|
| 75 | - $appName = $input->getArgument('app'); |
|
| 76 | - $configName = $input->getArgument('name'); |
|
| 74 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 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 | } |
@@ -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,65 +29,65 @@ |
||
| 29 | 29 | use Symfony\Component\Console\Output\OutputInterface; |
| 30 | 30 | |
| 31 | 31 | class GetConfig 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:get') |
|
| 48 | - ->setDescription('Get 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 get' |
|
| 58 | - ) |
|
| 59 | - ->addOption( |
|
| 60 | - 'default-value', |
|
| 61 | - null, |
|
| 62 | - InputOption::VALUE_OPTIONAL, |
|
| 63 | - 'If no default value is set and the config does not exist, the command will exit with 1' |
|
| 64 | - ) |
|
| 65 | - ; |
|
| 66 | - } |
|
| 46 | + $this |
|
| 47 | + ->setName('config:app:get') |
|
| 48 | + ->setDescription('Get 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 get' |
|
| 58 | + ) |
|
| 59 | + ->addOption( |
|
| 60 | + 'default-value', |
|
| 61 | + null, |
|
| 62 | + InputOption::VALUE_OPTIONAL, |
|
| 63 | + 'If no default value is set and the config does not exist, the command will exit with 1' |
|
| 64 | + ) |
|
| 65 | + ; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * Executes the current command. |
|
| 70 | - * |
|
| 71 | - * @param InputInterface $input An InputInterface instance |
|
| 72 | - * @param OutputInterface $output An OutputInterface instance |
|
| 73 | - * @return null|int null or 0 if everything went fine, or an error code |
|
| 74 | - */ |
|
| 75 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 76 | - $appName = $input->getArgument('app'); |
|
| 77 | - $configName = $input->getArgument('name'); |
|
| 78 | - $defaultValue = $input->getOption('default-value'); |
|
| 68 | + /** |
|
| 69 | + * Executes the current command. |
|
| 70 | + * |
|
| 71 | + * @param InputInterface $input An InputInterface instance |
|
| 72 | + * @param OutputInterface $output An OutputInterface instance |
|
| 73 | + * @return null|int null or 0 if everything went fine, or an error code |
|
| 74 | + */ |
|
| 75 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 76 | + $appName = $input->getArgument('app'); |
|
| 77 | + $configName = $input->getArgument('name'); |
|
| 78 | + $defaultValue = $input->getOption('default-value'); |
|
| 79 | 79 | |
| 80 | - if (!in_array($configName, $this->config->getAppKeys($appName)) && !$input->hasParameterOption('--default-value')) { |
|
| 81 | - return 1; |
|
| 82 | - } |
|
| 80 | + if (!in_array($configName, $this->config->getAppKeys($appName)) && !$input->hasParameterOption('--default-value')) { |
|
| 81 | + return 1; |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - if (!in_array($configName, $this->config->getAppKeys($appName))) { |
|
| 85 | - $configValue = $defaultValue; |
|
| 86 | - } else { |
|
| 87 | - $configValue = $this->config->getAppValue($appName, $configName); |
|
| 88 | - } |
|
| 84 | + if (!in_array($configName, $this->config->getAppKeys($appName))) { |
|
| 85 | + $configValue = $defaultValue; |
|
| 86 | + } else { |
|
| 87 | + $configValue = $this->config->getAppValue($appName, $configName); |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - $this->writeMixedInOutputFormat($input, $output, $configValue); |
|
| 91 | - return 0; |
|
| 92 | - } |
|
| 90 | + $this->writeMixedInOutputFormat($input, $output, $configValue); |
|
| 91 | + return 0; |
|
| 92 | + } |
|
| 93 | 93 | } |
@@ -30,25 +30,25 @@ |
||
| 30 | 30 | |
| 31 | 31 | class DataFingerprint extends Command { |
| 32 | 32 | |
| 33 | - /** @var IConfig */ |
|
| 34 | - protected $config; |
|
| 35 | - /** @var ITimeFactory */ |
|
| 36 | - protected $timeFactory; |
|
| 33 | + /** @var IConfig */ |
|
| 34 | + protected $config; |
|
| 35 | + /** @var ITimeFactory */ |
|
| 36 | + protected $timeFactory; |
|
| 37 | 37 | |
| 38 | - public function __construct(IConfig $config, |
|
| 39 | - ITimeFactory $timeFactory) { |
|
| 40 | - $this->config = $config; |
|
| 41 | - $this->timeFactory = $timeFactory; |
|
| 42 | - parent::__construct(); |
|
| 43 | - } |
|
| 38 | + public function __construct(IConfig $config, |
|
| 39 | + ITimeFactory $timeFactory) { |
|
| 40 | + $this->config = $config; |
|
| 41 | + $this->timeFactory = $timeFactory; |
|
| 42 | + parent::__construct(); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - protected function configure() { |
|
| 46 | - $this |
|
| 47 | - ->setName('maintenance:data-fingerprint') |
|
| 48 | - ->setDescription('update the systems data-fingerprint after a backup is restored'); |
|
| 49 | - } |
|
| 45 | + protected function configure() { |
|
| 46 | + $this |
|
| 47 | + ->setName('maintenance:data-fingerprint') |
|
| 48 | + ->setDescription('update the systems data-fingerprint after a backup is restored'); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 52 | - $this->config->setSystemValue('data-fingerprint', md5($this->timeFactory->getTime())); |
|
| 53 | - } |
|
| 51 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 52 | + $this->config->setSystemValue('data-fingerprint', md5($this->timeFactory->getTime())); |
|
| 53 | + } |
|
| 54 | 54 | } |
@@ -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 | } |
@@ -38,120 +38,120 @@ |
||
| 38 | 38 | use Symfony\Component\EventDispatcher\GenericEvent; |
| 39 | 39 | |
| 40 | 40 | class Repair extends Command { |
| 41 | - /** @var \OC\Repair $repair */ |
|
| 42 | - protected $repair; |
|
| 43 | - /** @var IConfig */ |
|
| 44 | - protected $config; |
|
| 45 | - /** @var EventDispatcherInterface */ |
|
| 46 | - private $dispatcher; |
|
| 47 | - /** @var ProgressBar */ |
|
| 48 | - private $progress; |
|
| 49 | - /** @var OutputInterface */ |
|
| 50 | - private $output; |
|
| 51 | - /** @var IAppManager */ |
|
| 52 | - private $appManager; |
|
| 41 | + /** @var \OC\Repair $repair */ |
|
| 42 | + protected $repair; |
|
| 43 | + /** @var IConfig */ |
|
| 44 | + protected $config; |
|
| 45 | + /** @var EventDispatcherInterface */ |
|
| 46 | + private $dispatcher; |
|
| 47 | + /** @var ProgressBar */ |
|
| 48 | + private $progress; |
|
| 49 | + /** @var OutputInterface */ |
|
| 50 | + private $output; |
|
| 51 | + /** @var IAppManager */ |
|
| 52 | + private $appManager; |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * @param \OC\Repair $repair |
|
| 56 | - * @param IConfig $config |
|
| 57 | - * @param EventDispatcherInterface $dispatcher |
|
| 58 | - * @param IAppManager $appManager |
|
| 59 | - */ |
|
| 60 | - public function __construct(\OC\Repair $repair, IConfig $config, EventDispatcherInterface $dispatcher, IAppManager $appManager) { |
|
| 61 | - $this->repair = $repair; |
|
| 62 | - $this->config = $config; |
|
| 63 | - $this->dispatcher = $dispatcher; |
|
| 64 | - $this->appManager = $appManager; |
|
| 65 | - parent::__construct(); |
|
| 66 | - } |
|
| 54 | + /** |
|
| 55 | + * @param \OC\Repair $repair |
|
| 56 | + * @param IConfig $config |
|
| 57 | + * @param EventDispatcherInterface $dispatcher |
|
| 58 | + * @param IAppManager $appManager |
|
| 59 | + */ |
|
| 60 | + public function __construct(\OC\Repair $repair, IConfig $config, EventDispatcherInterface $dispatcher, IAppManager $appManager) { |
|
| 61 | + $this->repair = $repair; |
|
| 62 | + $this->config = $config; |
|
| 63 | + $this->dispatcher = $dispatcher; |
|
| 64 | + $this->appManager = $appManager; |
|
| 65 | + parent::__construct(); |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - protected function configure() { |
|
| 69 | - $this |
|
| 70 | - ->setName('maintenance:repair') |
|
| 71 | - ->setDescription('repair this installation') |
|
| 72 | - ->addOption( |
|
| 73 | - 'include-expensive', |
|
| 74 | - null, |
|
| 75 | - InputOption::VALUE_NONE, |
|
| 76 | - 'Use this option when you want to include resource and load expensive tasks'); |
|
| 77 | - } |
|
| 68 | + protected function configure() { |
|
| 69 | + $this |
|
| 70 | + ->setName('maintenance:repair') |
|
| 71 | + ->setDescription('repair this installation') |
|
| 72 | + ->addOption( |
|
| 73 | + 'include-expensive', |
|
| 74 | + null, |
|
| 75 | + InputOption::VALUE_NONE, |
|
| 76 | + 'Use this option when you want to include resource and load expensive tasks'); |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 80 | - $repairSteps = $this->repair::getRepairSteps(); |
|
| 79 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 80 | + $repairSteps = $this->repair::getRepairSteps(); |
|
| 81 | 81 | |
| 82 | - if ($input->getOption('include-expensive')) { |
|
| 83 | - $repairSteps = array_merge($repairSteps, $this->repair::getExpensiveRepairSteps()); |
|
| 84 | - } |
|
| 82 | + if ($input->getOption('include-expensive')) { |
|
| 83 | + $repairSteps = array_merge($repairSteps, $this->repair::getExpensiveRepairSteps()); |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - foreach ($repairSteps as $step) { |
|
| 87 | - $this->repair->addStep($step); |
|
| 88 | - } |
|
| 86 | + foreach ($repairSteps as $step) { |
|
| 87 | + $this->repair->addStep($step); |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - $apps = $this->appManager->getInstalledApps(); |
|
| 91 | - foreach ($apps as $app) { |
|
| 92 | - if (!$this->appManager->isEnabledForUser($app)) { |
|
| 93 | - continue; |
|
| 94 | - } |
|
| 95 | - $info = \OC_App::getAppInfo($app); |
|
| 96 | - if (!is_array($info)) { |
|
| 97 | - continue; |
|
| 98 | - } |
|
| 99 | - \OC_App::loadApp($app); |
|
| 100 | - $steps = $info['repair-steps']['post-migration']; |
|
| 101 | - foreach ($steps as $step) { |
|
| 102 | - try { |
|
| 103 | - $this->repair->addStep($step); |
|
| 104 | - } catch (Exception $ex) { |
|
| 105 | - $output->writeln("<error>Failed to load repair step for $app: {$ex->getMessage()}</error>"); |
|
| 106 | - } |
|
| 107 | - } |
|
| 108 | - } |
|
| 90 | + $apps = $this->appManager->getInstalledApps(); |
|
| 91 | + foreach ($apps as $app) { |
|
| 92 | + if (!$this->appManager->isEnabledForUser($app)) { |
|
| 93 | + continue; |
|
| 94 | + } |
|
| 95 | + $info = \OC_App::getAppInfo($app); |
|
| 96 | + if (!is_array($info)) { |
|
| 97 | + continue; |
|
| 98 | + } |
|
| 99 | + \OC_App::loadApp($app); |
|
| 100 | + $steps = $info['repair-steps']['post-migration']; |
|
| 101 | + foreach ($steps as $step) { |
|
| 102 | + try { |
|
| 103 | + $this->repair->addStep($step); |
|
| 104 | + } catch (Exception $ex) { |
|
| 105 | + $output->writeln("<error>Failed to load repair step for $app: {$ex->getMessage()}</error>"); |
|
| 106 | + } |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - $maintenanceMode = $this->config->getSystemValueBool('maintenance'); |
|
| 111 | - $this->config->setSystemValue('maintenance', true); |
|
| 110 | + $maintenanceMode = $this->config->getSystemValueBool('maintenance'); |
|
| 111 | + $this->config->setSystemValue('maintenance', true); |
|
| 112 | 112 | |
| 113 | - $this->progress = new ProgressBar($output); |
|
| 114 | - $this->output = $output; |
|
| 115 | - $this->dispatcher->addListener('\OC\Repair::startProgress', [$this, 'handleRepairFeedBack']); |
|
| 116 | - $this->dispatcher->addListener('\OC\Repair::advance', [$this, 'handleRepairFeedBack']); |
|
| 117 | - $this->dispatcher->addListener('\OC\Repair::finishProgress', [$this, 'handleRepairFeedBack']); |
|
| 118 | - $this->dispatcher->addListener('\OC\Repair::step', [$this, 'handleRepairFeedBack']); |
|
| 119 | - $this->dispatcher->addListener('\OC\Repair::info', [$this, 'handleRepairFeedBack']); |
|
| 120 | - $this->dispatcher->addListener('\OC\Repair::warning', [$this, 'handleRepairFeedBack']); |
|
| 121 | - $this->dispatcher->addListener('\OC\Repair::error', [$this, 'handleRepairFeedBack']); |
|
| 113 | + $this->progress = new ProgressBar($output); |
|
| 114 | + $this->output = $output; |
|
| 115 | + $this->dispatcher->addListener('\OC\Repair::startProgress', [$this, 'handleRepairFeedBack']); |
|
| 116 | + $this->dispatcher->addListener('\OC\Repair::advance', [$this, 'handleRepairFeedBack']); |
|
| 117 | + $this->dispatcher->addListener('\OC\Repair::finishProgress', [$this, 'handleRepairFeedBack']); |
|
| 118 | + $this->dispatcher->addListener('\OC\Repair::step', [$this, 'handleRepairFeedBack']); |
|
| 119 | + $this->dispatcher->addListener('\OC\Repair::info', [$this, 'handleRepairFeedBack']); |
|
| 120 | + $this->dispatcher->addListener('\OC\Repair::warning', [$this, 'handleRepairFeedBack']); |
|
| 121 | + $this->dispatcher->addListener('\OC\Repair::error', [$this, 'handleRepairFeedBack']); |
|
| 122 | 122 | |
| 123 | - $this->repair->run(); |
|
| 123 | + $this->repair->run(); |
|
| 124 | 124 | |
| 125 | - $this->config->setSystemValue('maintenance', $maintenanceMode); |
|
| 126 | - } |
|
| 125 | + $this->config->setSystemValue('maintenance', $maintenanceMode); |
|
| 126 | + } |
|
| 127 | 127 | |
| 128 | - public function handleRepairFeedBack($event) { |
|
| 129 | - if (!$event instanceof GenericEvent) { |
|
| 130 | - return; |
|
| 131 | - } |
|
| 132 | - switch ($event->getSubject()) { |
|
| 133 | - case '\OC\Repair::startProgress': |
|
| 134 | - $this->progress->start($event->getArgument(0)); |
|
| 135 | - break; |
|
| 136 | - case '\OC\Repair::advance': |
|
| 137 | - $this->progress->advance($event->getArgument(0)); |
|
| 138 | - break; |
|
| 139 | - case '\OC\Repair::finishProgress': |
|
| 140 | - $this->progress->finish(); |
|
| 141 | - $this->output->writeln(''); |
|
| 142 | - break; |
|
| 143 | - case '\OC\Repair::step': |
|
| 144 | - $this->output->writeln(' - ' . $event->getArgument(0)); |
|
| 145 | - break; |
|
| 146 | - case '\OC\Repair::info': |
|
| 147 | - $this->output->writeln(' - ' . $event->getArgument(0)); |
|
| 148 | - break; |
|
| 149 | - case '\OC\Repair::warning': |
|
| 150 | - $this->output->writeln(' - WARNING: ' . $event->getArgument(0)); |
|
| 151 | - break; |
|
| 152 | - case '\OC\Repair::error': |
|
| 153 | - $this->output->writeln(' - ERROR: ' . $event->getArgument(0)); |
|
| 154 | - break; |
|
| 155 | - } |
|
| 156 | - } |
|
| 128 | + public function handleRepairFeedBack($event) { |
|
| 129 | + if (!$event instanceof GenericEvent) { |
|
| 130 | + return; |
|
| 131 | + } |
|
| 132 | + switch ($event->getSubject()) { |
|
| 133 | + case '\OC\Repair::startProgress': |
|
| 134 | + $this->progress->start($event->getArgument(0)); |
|
| 135 | + break; |
|
| 136 | + case '\OC\Repair::advance': |
|
| 137 | + $this->progress->advance($event->getArgument(0)); |
|
| 138 | + break; |
|
| 139 | + case '\OC\Repair::finishProgress': |
|
| 140 | + $this->progress->finish(); |
|
| 141 | + $this->output->writeln(''); |
|
| 142 | + break; |
|
| 143 | + case '\OC\Repair::step': |
|
| 144 | + $this->output->writeln(' - ' . $event->getArgument(0)); |
|
| 145 | + break; |
|
| 146 | + case '\OC\Repair::info': |
|
| 147 | + $this->output->writeln(' - ' . $event->getArgument(0)); |
|
| 148 | + break; |
|
| 149 | + case '\OC\Repair::warning': |
|
| 150 | + $this->output->writeln(' - WARNING: ' . $event->getArgument(0)); |
|
| 151 | + break; |
|
| 152 | + case '\OC\Repair::error': |
|
| 153 | + $this->output->writeln(' - ERROR: ' . $event->getArgument(0)); |
|
| 154 | + break; |
|
| 155 | + } |
|
| 156 | + } |
|
| 157 | 157 | } |
@@ -29,48 +29,48 @@ |
||
| 29 | 29 | use Symfony\Component\Console\Output\OutputInterface; |
| 30 | 30 | |
| 31 | 31 | class GetPath extends Base { |
| 32 | - protected function configure() { |
|
| 33 | - parent::configure(); |
|
| 32 | + protected function configure() { |
|
| 33 | + parent::configure(); |
|
| 34 | 34 | |
| 35 | - $this |
|
| 36 | - ->setName('app:getpath') |
|
| 37 | - ->setDescription('Get an absolute path to the app directory') |
|
| 38 | - ->addArgument( |
|
| 39 | - 'app', |
|
| 40 | - InputArgument::REQUIRED, |
|
| 41 | - 'Name of the app' |
|
| 42 | - ) |
|
| 43 | - ; |
|
| 44 | - } |
|
| 35 | + $this |
|
| 36 | + ->setName('app:getpath') |
|
| 37 | + ->setDescription('Get an absolute path to the app directory') |
|
| 38 | + ->addArgument( |
|
| 39 | + 'app', |
|
| 40 | + InputArgument::REQUIRED, |
|
| 41 | + 'Name of the app' |
|
| 42 | + ) |
|
| 43 | + ; |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * Executes the current command. |
|
| 48 | - * |
|
| 49 | - * @param InputInterface $input An InputInterface instance |
|
| 50 | - * @param OutputInterface $output An OutputInterface instance |
|
| 51 | - * @return null|int null or 0 if everything went fine, or an error code |
|
| 52 | - */ |
|
| 53 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 54 | - $appName = $input->getArgument('app'); |
|
| 55 | - $path = \OC_App::getAppPath($appName); |
|
| 56 | - if ($path !== false) { |
|
| 57 | - $output->writeln($path); |
|
| 58 | - return 0; |
|
| 59 | - } |
|
| 46 | + /** |
|
| 47 | + * Executes the current command. |
|
| 48 | + * |
|
| 49 | + * @param InputInterface $input An InputInterface instance |
|
| 50 | + * @param OutputInterface $output An OutputInterface instance |
|
| 51 | + * @return null|int null or 0 if everything went fine, or an error code |
|
| 52 | + */ |
|
| 53 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 54 | + $appName = $input->getArgument('app'); |
|
| 55 | + $path = \OC_App::getAppPath($appName); |
|
| 56 | + if ($path !== false) { |
|
| 57 | + $output->writeln($path); |
|
| 58 | + return 0; |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - // App not found, exit with non-zero |
|
| 62 | - return 1; |
|
| 63 | - } |
|
| 61 | + // App not found, exit with non-zero |
|
| 62 | + return 1; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * @param string $argumentName |
|
| 67 | - * @param CompletionContext $context |
|
| 68 | - * @return string[] |
|
| 69 | - */ |
|
| 70 | - public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
| 71 | - if ($argumentName === 'app') { |
|
| 72 | - return \OC_App::getAllApps(); |
|
| 73 | - } |
|
| 74 | - return []; |
|
| 75 | - } |
|
| 65 | + /** |
|
| 66 | + * @param string $argumentName |
|
| 67 | + * @param CompletionContext $context |
|
| 68 | + * @return string[] |
|
| 69 | + */ |
|
| 70 | + public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
| 71 | + if ($argumentName === 'app') { |
|
| 72 | + return \OC_App::getAllApps(); |
|
| 73 | + } |
|
| 74 | + return []; |
|
| 75 | + } |
|
| 76 | 76 | } |
@@ -28,30 +28,30 @@ |
||
| 28 | 28 | use Symfony\Component\Console\Output\OutputInterface; |
| 29 | 29 | |
| 30 | 30 | class Disable extends Command { |
| 31 | - /** @var IConfig */ |
|
| 32 | - protected $config; |
|
| 31 | + /** @var IConfig */ |
|
| 32 | + protected $config; |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * @param IConfig $config |
|
| 36 | - */ |
|
| 37 | - public function __construct(IConfig $config) { |
|
| 38 | - parent::__construct(); |
|
| 39 | - $this->config = $config; |
|
| 40 | - } |
|
| 34 | + /** |
|
| 35 | + * @param IConfig $config |
|
| 36 | + */ |
|
| 37 | + public function __construct(IConfig $config) { |
|
| 38 | + parent::__construct(); |
|
| 39 | + $this->config = $config; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - protected function configure() { |
|
| 43 | - $this |
|
| 44 | - ->setName('encryption:disable') |
|
| 45 | - ->setDescription('Disable encryption') |
|
| 46 | - ; |
|
| 47 | - } |
|
| 42 | + protected function configure() { |
|
| 43 | + $this |
|
| 44 | + ->setName('encryption:disable') |
|
| 45 | + ->setDescription('Disable encryption') |
|
| 46 | + ; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 50 | - if ($this->config->getAppValue('core', 'encryption_enabled', 'no') !== 'yes') { |
|
| 51 | - $output->writeln('Encryption is already disabled'); |
|
| 52 | - } else { |
|
| 53 | - $this->config->setAppValue('core', 'encryption_enabled', 'no'); |
|
| 54 | - $output->writeln('<info>Encryption disabled</info>'); |
|
| 55 | - } |
|
| 56 | - } |
|
| 49 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 50 | + if ($this->config->getAppValue('core', 'encryption_enabled', 'no') !== 'yes') { |
|
| 51 | + $output->writeln('Encryption is already disabled'); |
|
| 52 | + } else { |
|
| 53 | + $this->config->setAppValue('core', 'encryption_enabled', 'no'); |
|
| 54 | + $output->writeln('<info>Encryption disabled</info>'); |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | 57 | } |