@@ -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,174 +32,174 @@ |
||
32 | 32 | use Symfony\Component\Console\Output\OutputInterface; |
33 | 33 | |
34 | 34 | class SetConfig extends Base { |
35 | - public function __construct(SystemConfig $systemConfig) { |
|
36 | - parent::__construct($systemConfig); |
|
37 | - } |
|
38 | - |
|
39 | - protected function configure() { |
|
40 | - parent::configure(); |
|
41 | - |
|
42 | - $this |
|
43 | - ->setName('config:system:set') |
|
44 | - ->setDescription('Set a system config value') |
|
45 | - ->addArgument( |
|
46 | - 'name', |
|
47 | - InputArgument::REQUIRED | InputArgument::IS_ARRAY, |
|
48 | - 'Name of the config parameter, specify multiple for array parameter' |
|
49 | - ) |
|
50 | - ->addOption( |
|
51 | - 'type', |
|
52 | - null, |
|
53 | - InputOption::VALUE_REQUIRED, |
|
54 | - 'Value type [string, integer, double, boolean]', |
|
55 | - 'string' |
|
56 | - ) |
|
57 | - ->addOption( |
|
58 | - 'value', |
|
59 | - null, |
|
60 | - InputOption::VALUE_REQUIRED, |
|
61 | - 'The new value of the config' |
|
62 | - ) |
|
63 | - ->addOption( |
|
64 | - 'update-only', |
|
65 | - null, |
|
66 | - InputOption::VALUE_NONE, |
|
67 | - 'Only updates the value, if it is not set before, it is not being added' |
|
68 | - ) |
|
69 | - ; |
|
70 | - } |
|
71 | - |
|
72 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
73 | - $configNames = $input->getArgument('name'); |
|
74 | - $configName = $configNames[0]; |
|
75 | - $configValue = $this->castValue($input->getOption('value'), $input->getOption('type')); |
|
76 | - $updateOnly = $input->getOption('update-only'); |
|
77 | - |
|
78 | - if (count($configNames) > 1) { |
|
79 | - $existingValue = $this->systemConfig->getValue($configName); |
|
80 | - |
|
81 | - $newValue = $this->mergeArrayValue( |
|
82 | - array_slice($configNames, 1), $existingValue, $configValue['value'], $updateOnly |
|
83 | - ); |
|
84 | - |
|
85 | - $this->systemConfig->setValue($configName, $newValue); |
|
86 | - } else { |
|
87 | - if ($updateOnly && !in_array($configName, $this->systemConfig->getKeys(), true)) { |
|
88 | - throw new \UnexpectedValueException('Config parameter does not exist'); |
|
89 | - } |
|
90 | - |
|
91 | - $this->systemConfig->setValue($configName, $configValue['value']); |
|
92 | - } |
|
93 | - |
|
94 | - $output->writeln('<info>System config value ' . implode(' => ', $configNames) . ' set to ' . $configValue['readable-value'] . '</info>'); |
|
95 | - return 0; |
|
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * @param string $value |
|
100 | - * @param string $type |
|
101 | - * @return mixed |
|
102 | - * @throws \InvalidArgumentException |
|
103 | - */ |
|
104 | - protected function castValue($value, $type) { |
|
105 | - switch ($type) { |
|
106 | - case 'integer': |
|
107 | - case 'int': |
|
108 | - if (!is_numeric($value)) { |
|
109 | - throw new \InvalidArgumentException('Non-numeric value specified'); |
|
110 | - } |
|
111 | - return [ |
|
112 | - 'value' => (int) $value, |
|
113 | - 'readable-value' => 'integer ' . (int) $value, |
|
114 | - ]; |
|
115 | - |
|
116 | - case 'double': |
|
117 | - case 'float': |
|
118 | - if (!is_numeric($value)) { |
|
119 | - throw new \InvalidArgumentException('Non-numeric value specified'); |
|
120 | - } |
|
121 | - return [ |
|
122 | - 'value' => (double) $value, |
|
123 | - 'readable-value' => 'double ' . (double) $value, |
|
124 | - ]; |
|
125 | - |
|
126 | - case 'boolean': |
|
127 | - case 'bool': |
|
128 | - $value = strtolower($value); |
|
129 | - switch ($value) { |
|
130 | - case 'true': |
|
131 | - return [ |
|
132 | - 'value' => true, |
|
133 | - 'readable-value' => 'boolean ' . $value, |
|
134 | - ]; |
|
135 | - |
|
136 | - case 'false': |
|
137 | - return [ |
|
138 | - 'value' => false, |
|
139 | - 'readable-value' => 'boolean ' . $value, |
|
140 | - ]; |
|
141 | - |
|
142 | - default: |
|
143 | - throw new \InvalidArgumentException('Unable to parse value as boolean'); |
|
144 | - } |
|
145 | - |
|
146 | - // no break |
|
147 | - case 'null': |
|
148 | - return [ |
|
149 | - 'value' => null, |
|
150 | - 'readable-value' => 'null', |
|
151 | - ]; |
|
152 | - |
|
153 | - case 'string': |
|
154 | - $value = (string) $value; |
|
155 | - return [ |
|
156 | - 'value' => $value, |
|
157 | - 'readable-value' => ($value === '') ? 'empty string' : 'string ' . $value, |
|
158 | - ]; |
|
159 | - |
|
160 | - default: |
|
161 | - throw new \InvalidArgumentException('Invalid type'); |
|
162 | - } |
|
163 | - } |
|
164 | - |
|
165 | - /** |
|
166 | - * @param array $configNames |
|
167 | - * @param mixed $existingValues |
|
168 | - * @param mixed $value |
|
169 | - * @param bool $updateOnly |
|
170 | - * @return array merged value |
|
171 | - * @throws \UnexpectedValueException |
|
172 | - */ |
|
173 | - protected function mergeArrayValue(array $configNames, $existingValues, $value, $updateOnly) { |
|
174 | - $configName = array_shift($configNames); |
|
175 | - if (!is_array($existingValues)) { |
|
176 | - $existingValues = []; |
|
177 | - } |
|
178 | - if (!empty($configNames)) { |
|
179 | - if (isset($existingValues[$configName])) { |
|
180 | - $existingValue = $existingValues[$configName]; |
|
181 | - } else { |
|
182 | - $existingValue = []; |
|
183 | - } |
|
184 | - $existingValues[$configName] = $this->mergeArrayValue($configNames, $existingValue, $value, $updateOnly); |
|
185 | - } else { |
|
186 | - if (!isset($existingValues[$configName]) && $updateOnly) { |
|
187 | - throw new \UnexpectedValueException('Config parameter does not exist'); |
|
188 | - } |
|
189 | - $existingValues[$configName] = $value; |
|
190 | - } |
|
191 | - return $existingValues; |
|
192 | - } |
|
193 | - |
|
194 | - /** |
|
195 | - * @param string $optionName |
|
196 | - * @param CompletionContext $context |
|
197 | - * @return string[] |
|
198 | - */ |
|
199 | - public function completeOptionValues($optionName, CompletionContext $context) { |
|
200 | - if ($optionName === 'type') { |
|
201 | - return ['string', 'integer', 'double', 'boolean']; |
|
202 | - } |
|
203 | - return parent::completeOptionValues($optionName, $context); |
|
204 | - } |
|
35 | + public function __construct(SystemConfig $systemConfig) { |
|
36 | + parent::__construct($systemConfig); |
|
37 | + } |
|
38 | + |
|
39 | + protected function configure() { |
|
40 | + parent::configure(); |
|
41 | + |
|
42 | + $this |
|
43 | + ->setName('config:system:set') |
|
44 | + ->setDescription('Set a system config value') |
|
45 | + ->addArgument( |
|
46 | + 'name', |
|
47 | + InputArgument::REQUIRED | InputArgument::IS_ARRAY, |
|
48 | + 'Name of the config parameter, specify multiple for array parameter' |
|
49 | + ) |
|
50 | + ->addOption( |
|
51 | + 'type', |
|
52 | + null, |
|
53 | + InputOption::VALUE_REQUIRED, |
|
54 | + 'Value type [string, integer, double, boolean]', |
|
55 | + 'string' |
|
56 | + ) |
|
57 | + ->addOption( |
|
58 | + 'value', |
|
59 | + null, |
|
60 | + InputOption::VALUE_REQUIRED, |
|
61 | + 'The new value of the config' |
|
62 | + ) |
|
63 | + ->addOption( |
|
64 | + 'update-only', |
|
65 | + null, |
|
66 | + InputOption::VALUE_NONE, |
|
67 | + 'Only updates the value, if it is not set before, it is not being added' |
|
68 | + ) |
|
69 | + ; |
|
70 | + } |
|
71 | + |
|
72 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
73 | + $configNames = $input->getArgument('name'); |
|
74 | + $configName = $configNames[0]; |
|
75 | + $configValue = $this->castValue($input->getOption('value'), $input->getOption('type')); |
|
76 | + $updateOnly = $input->getOption('update-only'); |
|
77 | + |
|
78 | + if (count($configNames) > 1) { |
|
79 | + $existingValue = $this->systemConfig->getValue($configName); |
|
80 | + |
|
81 | + $newValue = $this->mergeArrayValue( |
|
82 | + array_slice($configNames, 1), $existingValue, $configValue['value'], $updateOnly |
|
83 | + ); |
|
84 | + |
|
85 | + $this->systemConfig->setValue($configName, $newValue); |
|
86 | + } else { |
|
87 | + if ($updateOnly && !in_array($configName, $this->systemConfig->getKeys(), true)) { |
|
88 | + throw new \UnexpectedValueException('Config parameter does not exist'); |
|
89 | + } |
|
90 | + |
|
91 | + $this->systemConfig->setValue($configName, $configValue['value']); |
|
92 | + } |
|
93 | + |
|
94 | + $output->writeln('<info>System config value ' . implode(' => ', $configNames) . ' set to ' . $configValue['readable-value'] . '</info>'); |
|
95 | + return 0; |
|
96 | + } |
|
97 | + |
|
98 | + /** |
|
99 | + * @param string $value |
|
100 | + * @param string $type |
|
101 | + * @return mixed |
|
102 | + * @throws \InvalidArgumentException |
|
103 | + */ |
|
104 | + protected function castValue($value, $type) { |
|
105 | + switch ($type) { |
|
106 | + case 'integer': |
|
107 | + case 'int': |
|
108 | + if (!is_numeric($value)) { |
|
109 | + throw new \InvalidArgumentException('Non-numeric value specified'); |
|
110 | + } |
|
111 | + return [ |
|
112 | + 'value' => (int) $value, |
|
113 | + 'readable-value' => 'integer ' . (int) $value, |
|
114 | + ]; |
|
115 | + |
|
116 | + case 'double': |
|
117 | + case 'float': |
|
118 | + if (!is_numeric($value)) { |
|
119 | + throw new \InvalidArgumentException('Non-numeric value specified'); |
|
120 | + } |
|
121 | + return [ |
|
122 | + 'value' => (double) $value, |
|
123 | + 'readable-value' => 'double ' . (double) $value, |
|
124 | + ]; |
|
125 | + |
|
126 | + case 'boolean': |
|
127 | + case 'bool': |
|
128 | + $value = strtolower($value); |
|
129 | + switch ($value) { |
|
130 | + case 'true': |
|
131 | + return [ |
|
132 | + 'value' => true, |
|
133 | + 'readable-value' => 'boolean ' . $value, |
|
134 | + ]; |
|
135 | + |
|
136 | + case 'false': |
|
137 | + return [ |
|
138 | + 'value' => false, |
|
139 | + 'readable-value' => 'boolean ' . $value, |
|
140 | + ]; |
|
141 | + |
|
142 | + default: |
|
143 | + throw new \InvalidArgumentException('Unable to parse value as boolean'); |
|
144 | + } |
|
145 | + |
|
146 | + // no break |
|
147 | + case 'null': |
|
148 | + return [ |
|
149 | + 'value' => null, |
|
150 | + 'readable-value' => 'null', |
|
151 | + ]; |
|
152 | + |
|
153 | + case 'string': |
|
154 | + $value = (string) $value; |
|
155 | + return [ |
|
156 | + 'value' => $value, |
|
157 | + 'readable-value' => ($value === '') ? 'empty string' : 'string ' . $value, |
|
158 | + ]; |
|
159 | + |
|
160 | + default: |
|
161 | + throw new \InvalidArgumentException('Invalid type'); |
|
162 | + } |
|
163 | + } |
|
164 | + |
|
165 | + /** |
|
166 | + * @param array $configNames |
|
167 | + * @param mixed $existingValues |
|
168 | + * @param mixed $value |
|
169 | + * @param bool $updateOnly |
|
170 | + * @return array merged value |
|
171 | + * @throws \UnexpectedValueException |
|
172 | + */ |
|
173 | + protected function mergeArrayValue(array $configNames, $existingValues, $value, $updateOnly) { |
|
174 | + $configName = array_shift($configNames); |
|
175 | + if (!is_array($existingValues)) { |
|
176 | + $existingValues = []; |
|
177 | + } |
|
178 | + if (!empty($configNames)) { |
|
179 | + if (isset($existingValues[$configName])) { |
|
180 | + $existingValue = $existingValues[$configName]; |
|
181 | + } else { |
|
182 | + $existingValue = []; |
|
183 | + } |
|
184 | + $existingValues[$configName] = $this->mergeArrayValue($configNames, $existingValue, $value, $updateOnly); |
|
185 | + } else { |
|
186 | + if (!isset($existingValues[$configName]) && $updateOnly) { |
|
187 | + throw new \UnexpectedValueException('Config parameter does not exist'); |
|
188 | + } |
|
189 | + $existingValues[$configName] = $value; |
|
190 | + } |
|
191 | + return $existingValues; |
|
192 | + } |
|
193 | + |
|
194 | + /** |
|
195 | + * @param string $optionName |
|
196 | + * @param CompletionContext $context |
|
197 | + * @return string[] |
|
198 | + */ |
|
199 | + public function completeOptionValues($optionName, CompletionContext $context) { |
|
200 | + if ($optionName === 'type') { |
|
201 | + return ['string', 'integer', 'double', 'boolean']; |
|
202 | + } |
|
203 | + return parent::completeOptionValues($optionName, $context); |
|
204 | + } |
|
205 | 205 | } |
@@ -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 | } |
@@ -28,52 +28,52 @@ |
||
28 | 28 | use Symfony\Component\Console\Output\OutputInterface; |
29 | 29 | |
30 | 30 | class DeleteConfig extends Base { |
31 | - protected IConfig $config; |
|
31 | + protected IConfig $config; |
|
32 | 32 | |
33 | - /** |
|
34 | - * @param IConfig $config |
|
35 | - */ |
|
36 | - public function __construct(IConfig $config) { |
|
37 | - parent::__construct(); |
|
38 | - $this->config = $config; |
|
39 | - } |
|
33 | + /** |
|
34 | + * @param IConfig $config |
|
35 | + */ |
|
36 | + public function __construct(IConfig $config) { |
|
37 | + parent::__construct(); |
|
38 | + $this->config = $config; |
|
39 | + } |
|
40 | 40 | |
41 | - protected function configure() { |
|
42 | - parent::configure(); |
|
41 | + protected function configure() { |
|
42 | + parent::configure(); |
|
43 | 43 | |
44 | - $this |
|
45 | - ->setName('config:app:delete') |
|
46 | - ->setDescription('Delete an app config value') |
|
47 | - ->addArgument( |
|
48 | - 'app', |
|
49 | - InputArgument::REQUIRED, |
|
50 | - 'Name of the app' |
|
51 | - ) |
|
52 | - ->addArgument( |
|
53 | - 'name', |
|
54 | - InputArgument::REQUIRED, |
|
55 | - 'Name of the config to delete' |
|
56 | - ) |
|
57 | - ->addOption( |
|
58 | - 'error-if-not-exists', |
|
59 | - null, |
|
60 | - InputOption::VALUE_NONE, |
|
61 | - 'Checks whether the config exists before deleting it' |
|
62 | - ) |
|
63 | - ; |
|
64 | - } |
|
44 | + $this |
|
45 | + ->setName('config:app:delete') |
|
46 | + ->setDescription('Delete an app config value') |
|
47 | + ->addArgument( |
|
48 | + 'app', |
|
49 | + InputArgument::REQUIRED, |
|
50 | + 'Name of the app' |
|
51 | + ) |
|
52 | + ->addArgument( |
|
53 | + 'name', |
|
54 | + InputArgument::REQUIRED, |
|
55 | + 'Name of the config to delete' |
|
56 | + ) |
|
57 | + ->addOption( |
|
58 | + 'error-if-not-exists', |
|
59 | + null, |
|
60 | + InputOption::VALUE_NONE, |
|
61 | + 'Checks whether the config exists before deleting it' |
|
62 | + ) |
|
63 | + ; |
|
64 | + } |
|
65 | 65 | |
66 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
67 | - $appName = $input->getArgument('app'); |
|
68 | - $configName = $input->getArgument('name'); |
|
66 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
67 | + $appName = $input->getArgument('app'); |
|
68 | + $configName = $input->getArgument('name'); |
|
69 | 69 | |
70 | - if ($input->hasParameterOption('--error-if-not-exists') && !in_array($configName, $this->config->getAppKeys($appName))) { |
|
71 | - $output->writeln('<error>Config ' . $configName . ' of app ' . $appName . ' could not be deleted because it did not exist</error>'); |
|
72 | - return 1; |
|
73 | - } |
|
70 | + if ($input->hasParameterOption('--error-if-not-exists') && !in_array($configName, $this->config->getAppKeys($appName))) { |
|
71 | + $output->writeln('<error>Config ' . $configName . ' of app ' . $appName . ' could not be deleted because it did not exist</error>'); |
|
72 | + return 1; |
|
73 | + } |
|
74 | 74 | |
75 | - $this->config->deleteAppValue($appName, $configName); |
|
76 | - $output->writeln('<info>Config value ' . $configName . ' of app ' . $appName . ' deleted</info>'); |
|
77 | - return 0; |
|
78 | - } |
|
75 | + $this->config->deleteAppValue($appName, $configName); |
|
76 | + $output->writeln('<info>Config value ' . $configName . ' of app ' . $appName . ' deleted</info>'); |
|
77 | + return 0; |
|
78 | + } |
|
79 | 79 | } |
@@ -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 | } |
@@ -28,57 +28,57 @@ |
||
28 | 28 | use Symfony\Component\Console\Output\OutputInterface; |
29 | 29 | |
30 | 30 | class SetConfig extends Base { |
31 | - protected IConfig $config; |
|
31 | + protected IConfig $config; |
|
32 | 32 | |
33 | - public function __construct(IConfig $config) { |
|
34 | - parent::__construct(); |
|
35 | - $this->config = $config; |
|
36 | - } |
|
33 | + public function __construct(IConfig $config) { |
|
34 | + parent::__construct(); |
|
35 | + $this->config = $config; |
|
36 | + } |
|
37 | 37 | |
38 | - protected function configure() { |
|
39 | - parent::configure(); |
|
38 | + protected function configure() { |
|
39 | + parent::configure(); |
|
40 | 40 | |
41 | - $this |
|
42 | - ->setName('config:app:set') |
|
43 | - ->setDescription('Set an app config value') |
|
44 | - ->addArgument( |
|
45 | - 'app', |
|
46 | - InputArgument::REQUIRED, |
|
47 | - 'Name of the app' |
|
48 | - ) |
|
49 | - ->addArgument( |
|
50 | - 'name', |
|
51 | - InputArgument::REQUIRED, |
|
52 | - 'Name of the config to set' |
|
53 | - ) |
|
54 | - ->addOption( |
|
55 | - 'value', |
|
56 | - null, |
|
57 | - InputOption::VALUE_REQUIRED, |
|
58 | - 'The new value of the config' |
|
59 | - ) |
|
60 | - ->addOption( |
|
61 | - 'update-only', |
|
62 | - null, |
|
63 | - InputOption::VALUE_NONE, |
|
64 | - 'Only updates the value, if it is not set before, it is not being added' |
|
65 | - ) |
|
66 | - ; |
|
67 | - } |
|
41 | + $this |
|
42 | + ->setName('config:app:set') |
|
43 | + ->setDescription('Set an app config value') |
|
44 | + ->addArgument( |
|
45 | + 'app', |
|
46 | + InputArgument::REQUIRED, |
|
47 | + 'Name of the app' |
|
48 | + ) |
|
49 | + ->addArgument( |
|
50 | + 'name', |
|
51 | + InputArgument::REQUIRED, |
|
52 | + 'Name of the config to set' |
|
53 | + ) |
|
54 | + ->addOption( |
|
55 | + 'value', |
|
56 | + null, |
|
57 | + InputOption::VALUE_REQUIRED, |
|
58 | + 'The new value of the config' |
|
59 | + ) |
|
60 | + ->addOption( |
|
61 | + 'update-only', |
|
62 | + null, |
|
63 | + InputOption::VALUE_NONE, |
|
64 | + 'Only updates the value, if it is not set before, it is not being added' |
|
65 | + ) |
|
66 | + ; |
|
67 | + } |
|
68 | 68 | |
69 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
70 | - $appName = $input->getArgument('app'); |
|
71 | - $configName = $input->getArgument('name'); |
|
69 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
70 | + $appName = $input->getArgument('app'); |
|
71 | + $configName = $input->getArgument('name'); |
|
72 | 72 | |
73 | - if (!in_array($configName, $this->config->getAppKeys($appName)) && $input->hasParameterOption('--update-only')) { |
|
74 | - $output->writeln('<comment>Config value ' . $configName . ' for app ' . $appName . ' not updated, as it has not been set before.</comment>'); |
|
75 | - return 1; |
|
76 | - } |
|
73 | + if (!in_array($configName, $this->config->getAppKeys($appName)) && $input->hasParameterOption('--update-only')) { |
|
74 | + $output->writeln('<comment>Config value ' . $configName . ' for app ' . $appName . ' not updated, as it has not been set before.</comment>'); |
|
75 | + return 1; |
|
76 | + } |
|
77 | 77 | |
78 | - $configValue = $input->getOption('value'); |
|
79 | - $this->config->setAppValue($appName, $configName, $configValue); |
|
78 | + $configValue = $input->getOption('value'); |
|
79 | + $this->config->setAppValue($appName, $configName, $configValue); |
|
80 | 80 | |
81 | - $output->writeln('<info>Config value ' . $configName . ' for app ' . $appName . ' set to ' . $configValue . '</info>'); |
|
82 | - return 0; |
|
83 | - } |
|
81 | + $output->writeln('<info>Config value ' . $configName . ' for app ' . $appName . ' set to ' . $configValue . '</info>'); |
|
82 | + return 0; |
|
83 | + } |
|
84 | 84 | } |
@@ -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 |
@@ -37,62 +37,62 @@ |
||
37 | 37 | use Symfony\Component\Console\Question\ConfirmationQuestion; |
38 | 38 | |
39 | 39 | class Delete extends Base { |
40 | - protected GlobalStoragesService $globalService; |
|
41 | - protected UserStoragesService $userService; |
|
42 | - protected IUserSession $userSession; |
|
43 | - protected IUserManager $userManager; |
|
40 | + protected GlobalStoragesService $globalService; |
|
41 | + protected UserStoragesService $userService; |
|
42 | + protected IUserSession $userSession; |
|
43 | + protected IUserManager $userManager; |
|
44 | 44 | |
45 | - public function __construct(GlobalStoragesService $globalService, UserStoragesService $userService, IUserSession $userSession, IUserManager $userManager) { |
|
46 | - parent::__construct(); |
|
47 | - $this->globalService = $globalService; |
|
48 | - $this->userService = $userService; |
|
49 | - $this->userSession = $userSession; |
|
50 | - $this->userManager = $userManager; |
|
51 | - } |
|
45 | + public function __construct(GlobalStoragesService $globalService, UserStoragesService $userService, IUserSession $userSession, IUserManager $userManager) { |
|
46 | + parent::__construct(); |
|
47 | + $this->globalService = $globalService; |
|
48 | + $this->userService = $userService; |
|
49 | + $this->userSession = $userSession; |
|
50 | + $this->userManager = $userManager; |
|
51 | + } |
|
52 | 52 | |
53 | - protected function configure(): void { |
|
54 | - $this |
|
55 | - ->setName('files_external:delete') |
|
56 | - ->setDescription('Delete an external mount') |
|
57 | - ->addArgument( |
|
58 | - 'mount_id', |
|
59 | - InputArgument::REQUIRED, |
|
60 | - 'The id of the mount to edit' |
|
61 | - )->addOption( |
|
62 | - 'yes', |
|
63 | - 'y', |
|
64 | - InputOption::VALUE_NONE, |
|
65 | - 'Skip confirmation' |
|
66 | - ); |
|
67 | - parent::configure(); |
|
68 | - } |
|
53 | + protected function configure(): void { |
|
54 | + $this |
|
55 | + ->setName('files_external:delete') |
|
56 | + ->setDescription('Delete an external mount') |
|
57 | + ->addArgument( |
|
58 | + 'mount_id', |
|
59 | + InputArgument::REQUIRED, |
|
60 | + 'The id of the mount to edit' |
|
61 | + )->addOption( |
|
62 | + 'yes', |
|
63 | + 'y', |
|
64 | + InputOption::VALUE_NONE, |
|
65 | + 'Skip confirmation' |
|
66 | + ); |
|
67 | + parent::configure(); |
|
68 | + } |
|
69 | 69 | |
70 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
71 | - $mountId = $input->getArgument('mount_id'); |
|
72 | - try { |
|
73 | - $mount = $this->globalService->getStorage($mountId); |
|
74 | - } catch (NotFoundException $e) { |
|
75 | - $output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts"</error>'); |
|
76 | - return 404; |
|
77 | - } |
|
70 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
71 | + $mountId = $input->getArgument('mount_id'); |
|
72 | + try { |
|
73 | + $mount = $this->globalService->getStorage($mountId); |
|
74 | + } catch (NotFoundException $e) { |
|
75 | + $output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts"</error>'); |
|
76 | + return 404; |
|
77 | + } |
|
78 | 78 | |
79 | - $noConfirm = $input->getOption('yes'); |
|
79 | + $noConfirm = $input->getOption('yes'); |
|
80 | 80 | |
81 | - if (!$noConfirm) { |
|
82 | - $listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager); |
|
83 | - $listInput = new ArrayInput([], $listCommand->getDefinition()); |
|
84 | - $listInput->setOption('output', $input->getOption('output')); |
|
85 | - $listCommand->listMounts(null, [$mount], $listInput, $output); |
|
81 | + if (!$noConfirm) { |
|
82 | + $listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager); |
|
83 | + $listInput = new ArrayInput([], $listCommand->getDefinition()); |
|
84 | + $listInput->setOption('output', $input->getOption('output')); |
|
85 | + $listCommand->listMounts(null, [$mount], $listInput, $output); |
|
86 | 86 | |
87 | - $questionHelper = $this->getHelper('question'); |
|
88 | - $question = new ConfirmationQuestion('Delete this mount? [y/N] ', false); |
|
87 | + $questionHelper = $this->getHelper('question'); |
|
88 | + $question = new ConfirmationQuestion('Delete this mount? [y/N] ', false); |
|
89 | 89 | |
90 | - if (!$questionHelper->ask($input, $output, $question)) { |
|
91 | - return 1; |
|
92 | - } |
|
93 | - } |
|
90 | + if (!$questionHelper->ask($input, $output, $question)) { |
|
91 | + return 1; |
|
92 | + } |
|
93 | + } |
|
94 | 94 | |
95 | - $this->globalService->removeStorage($mountId); |
|
96 | - return 0; |
|
97 | - } |
|
95 | + $this->globalService->removeStorage($mountId); |
|
96 | + return 0; |
|
97 | + } |
|
98 | 98 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | |
72 | 72 | $updatedEntries = $builder->execute(); |
73 | 73 | if ($updatedEntries > 0) { |
74 | - $out->info('Fixed file share permissions for ' . $updatedEntries . ' shares'); |
|
74 | + $out->info('Fixed file share permissions for '.$updatedEntries.' shares'); |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | } |
108 | 108 | |
109 | 109 | if ($deletedEntries) { |
110 | - $out->info('Removed ' . $deletedEntries . ' shares where the parent did not exist'); |
|
110 | + $out->info('Removed '.$deletedEntries.' shares where the parent did not exist'); |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 |
@@ -33,89 +33,89 @@ |
||
33 | 33 | * Repairs shares with invalid data |
34 | 34 | */ |
35 | 35 | class RepairInvalidShares implements IRepairStep { |
36 | - public const CHUNK_SIZE = 200; |
|
37 | - |
|
38 | - /** @var \OCP\IConfig */ |
|
39 | - protected $config; |
|
40 | - |
|
41 | - /** @var \OCP\IDBConnection */ |
|
42 | - protected $connection; |
|
43 | - |
|
44 | - /** |
|
45 | - * @param \OCP\IConfig $config |
|
46 | - * @param \OCP\IDBConnection $connection |
|
47 | - */ |
|
48 | - public function __construct($config, $connection) { |
|
49 | - $this->connection = $connection; |
|
50 | - $this->config = $config; |
|
51 | - } |
|
52 | - |
|
53 | - public function getName() { |
|
54 | - return 'Repair invalid shares'; |
|
55 | - } |
|
56 | - |
|
57 | - /** |
|
58 | - * Adjust file share permissions |
|
59 | - */ |
|
60 | - private function adjustFileSharePermissions(IOutput $out) { |
|
61 | - $mask = \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE; |
|
62 | - $builder = $this->connection->getQueryBuilder(); |
|
63 | - |
|
64 | - $permsFunc = $builder->expr()->bitwiseAnd('permissions', $mask); |
|
65 | - $builder |
|
66 | - ->update('share') |
|
67 | - ->set('permissions', $permsFunc) |
|
68 | - ->where($builder->expr()->eq('item_type', $builder->expr()->literal('file'))) |
|
69 | - ->andWhere($builder->expr()->neq('permissions', $permsFunc)); |
|
70 | - |
|
71 | - $updatedEntries = $builder->execute(); |
|
72 | - if ($updatedEntries > 0) { |
|
73 | - $out->info('Fixed file share permissions for ' . $updatedEntries . ' shares'); |
|
74 | - } |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * Remove shares where the parent share does not exist anymore |
|
79 | - */ |
|
80 | - private function removeSharesNonExistingParent(IOutput $out) { |
|
81 | - $deletedEntries = 0; |
|
82 | - |
|
83 | - $query = $this->connection->getQueryBuilder(); |
|
84 | - $query->select('s1.parent') |
|
85 | - ->from('share', 's1') |
|
86 | - ->where($query->expr()->isNotNull('s1.parent')) |
|
87 | - ->andWhere($query->expr()->isNull('s2.id')) |
|
88 | - ->leftJoin('s1', 'share', 's2', $query->expr()->eq('s1.parent', 's2.id')) |
|
89 | - ->groupBy('s1.parent') |
|
90 | - ->setMaxResults(self::CHUNK_SIZE); |
|
91 | - |
|
92 | - $deleteQuery = $this->connection->getQueryBuilder(); |
|
93 | - $deleteQuery->delete('share') |
|
94 | - ->where($deleteQuery->expr()->eq('parent', $deleteQuery->createParameter('parent'))); |
|
95 | - |
|
96 | - $deletedInLastChunk = self::CHUNK_SIZE; |
|
97 | - while ($deletedInLastChunk === self::CHUNK_SIZE) { |
|
98 | - $deletedInLastChunk = 0; |
|
99 | - $result = $query->execute(); |
|
100 | - while ($row = $result->fetch()) { |
|
101 | - $deletedInLastChunk++; |
|
102 | - $deletedEntries += $deleteQuery->setParameter('parent', (int) $row['parent']) |
|
103 | - ->execute(); |
|
104 | - } |
|
105 | - $result->closeCursor(); |
|
106 | - } |
|
107 | - |
|
108 | - if ($deletedEntries) { |
|
109 | - $out->info('Removed ' . $deletedEntries . ' shares where the parent did not exist'); |
|
110 | - } |
|
111 | - } |
|
112 | - |
|
113 | - public function run(IOutput $out) { |
|
114 | - $ocVersionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0'); |
|
115 | - if (version_compare($ocVersionFromBeforeUpdate, '12.0.0.11', '<')) { |
|
116 | - $this->adjustFileSharePermissions($out); |
|
117 | - } |
|
118 | - |
|
119 | - $this->removeSharesNonExistingParent($out); |
|
120 | - } |
|
36 | + public const CHUNK_SIZE = 200; |
|
37 | + |
|
38 | + /** @var \OCP\IConfig */ |
|
39 | + protected $config; |
|
40 | + |
|
41 | + /** @var \OCP\IDBConnection */ |
|
42 | + protected $connection; |
|
43 | + |
|
44 | + /** |
|
45 | + * @param \OCP\IConfig $config |
|
46 | + * @param \OCP\IDBConnection $connection |
|
47 | + */ |
|
48 | + public function __construct($config, $connection) { |
|
49 | + $this->connection = $connection; |
|
50 | + $this->config = $config; |
|
51 | + } |
|
52 | + |
|
53 | + public function getName() { |
|
54 | + return 'Repair invalid shares'; |
|
55 | + } |
|
56 | + |
|
57 | + /** |
|
58 | + * Adjust file share permissions |
|
59 | + */ |
|
60 | + private function adjustFileSharePermissions(IOutput $out) { |
|
61 | + $mask = \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE; |
|
62 | + $builder = $this->connection->getQueryBuilder(); |
|
63 | + |
|
64 | + $permsFunc = $builder->expr()->bitwiseAnd('permissions', $mask); |
|
65 | + $builder |
|
66 | + ->update('share') |
|
67 | + ->set('permissions', $permsFunc) |
|
68 | + ->where($builder->expr()->eq('item_type', $builder->expr()->literal('file'))) |
|
69 | + ->andWhere($builder->expr()->neq('permissions', $permsFunc)); |
|
70 | + |
|
71 | + $updatedEntries = $builder->execute(); |
|
72 | + if ($updatedEntries > 0) { |
|
73 | + $out->info('Fixed file share permissions for ' . $updatedEntries . ' shares'); |
|
74 | + } |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * Remove shares where the parent share does not exist anymore |
|
79 | + */ |
|
80 | + private function removeSharesNonExistingParent(IOutput $out) { |
|
81 | + $deletedEntries = 0; |
|
82 | + |
|
83 | + $query = $this->connection->getQueryBuilder(); |
|
84 | + $query->select('s1.parent') |
|
85 | + ->from('share', 's1') |
|
86 | + ->where($query->expr()->isNotNull('s1.parent')) |
|
87 | + ->andWhere($query->expr()->isNull('s2.id')) |
|
88 | + ->leftJoin('s1', 'share', 's2', $query->expr()->eq('s1.parent', 's2.id')) |
|
89 | + ->groupBy('s1.parent') |
|
90 | + ->setMaxResults(self::CHUNK_SIZE); |
|
91 | + |
|
92 | + $deleteQuery = $this->connection->getQueryBuilder(); |
|
93 | + $deleteQuery->delete('share') |
|
94 | + ->where($deleteQuery->expr()->eq('parent', $deleteQuery->createParameter('parent'))); |
|
95 | + |
|
96 | + $deletedInLastChunk = self::CHUNK_SIZE; |
|
97 | + while ($deletedInLastChunk === self::CHUNK_SIZE) { |
|
98 | + $deletedInLastChunk = 0; |
|
99 | + $result = $query->execute(); |
|
100 | + while ($row = $result->fetch()) { |
|
101 | + $deletedInLastChunk++; |
|
102 | + $deletedEntries += $deleteQuery->setParameter('parent', (int) $row['parent']) |
|
103 | + ->execute(); |
|
104 | + } |
|
105 | + $result->closeCursor(); |
|
106 | + } |
|
107 | + |
|
108 | + if ($deletedEntries) { |
|
109 | + $out->info('Removed ' . $deletedEntries . ' shares where the parent did not exist'); |
|
110 | + } |
|
111 | + } |
|
112 | + |
|
113 | + public function run(IOutput $out) { |
|
114 | + $ocVersionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0'); |
|
115 | + if (version_compare($ocVersionFromBeforeUpdate, '12.0.0.11', '<')) { |
|
116 | + $this->adjustFileSharePermissions($out); |
|
117 | + } |
|
118 | + |
|
119 | + $this->removeSharesNonExistingParent($out); |
|
120 | + } |
|
121 | 121 | } |
@@ -21,7 +21,7 @@ |
||
21 | 21 | */ |
22 | 22 | // no php execution timeout for webdav |
23 | 23 | if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { |
24 | - @set_time_limit(0); |
|
24 | + @set_time_limit(0); |
|
25 | 25 | } |
26 | 26 | ignore_user_abort(true); |
27 | 27 |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | } |
215 | 215 | |
216 | 216 | if ($provider === null) { |
217 | - throw new ProviderException('No provider with id .' . $id . ' found.'); |
|
217 | + throw new ProviderException('No provider with id .'.$id.' found.'); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | return $provider; |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | |
242 | 242 | |
243 | 243 | if ($provider === null) { |
244 | - throw new ProviderException('No share provider for share type ' . $shareType); |
|
244 | + throw new ProviderException('No share provider for share type '.$shareType); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | return $provider; |
@@ -57,335 +57,335 @@ |
||
57 | 57 | */ |
58 | 58 | class ProviderFactory implements IProviderFactory { |
59 | 59 | |
60 | - /** @var IServerContainer */ |
|
61 | - private $serverContainer; |
|
62 | - /** @var DefaultShareProvider */ |
|
63 | - private $defaultProvider = null; |
|
64 | - /** @var FederatedShareProvider */ |
|
65 | - private $federatedProvider = null; |
|
66 | - /** @var ShareByMailProvider */ |
|
67 | - private $shareByMailProvider; |
|
68 | - /** @var \OCA\Circles\ShareByCircleProvider */ |
|
69 | - private $shareByCircleProvider = null; |
|
70 | - /** @var bool */ |
|
71 | - private $circlesAreNotAvailable = false; |
|
72 | - /** @var \OCA\Talk\Share\RoomShareProvider */ |
|
73 | - private $roomShareProvider = null; |
|
74 | - |
|
75 | - private $registeredShareProviders = []; |
|
76 | - |
|
77 | - private $shareProviders = []; |
|
78 | - |
|
79 | - /** |
|
80 | - * IProviderFactory constructor. |
|
81 | - * |
|
82 | - * @param IServerContainer $serverContainer |
|
83 | - */ |
|
84 | - public function __construct(IServerContainer $serverContainer) { |
|
85 | - $this->serverContainer = $serverContainer; |
|
86 | - } |
|
87 | - |
|
88 | - public function registerProvider(string $shareProviderClass): void { |
|
89 | - $this->registeredShareProviders[] = $shareProviderClass; |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * Create the default share provider. |
|
94 | - * |
|
95 | - * @return DefaultShareProvider |
|
96 | - */ |
|
97 | - protected function defaultShareProvider() { |
|
98 | - if ($this->defaultProvider === null) { |
|
99 | - $this->defaultProvider = new DefaultShareProvider( |
|
100 | - $this->serverContainer->getDatabaseConnection(), |
|
101 | - $this->serverContainer->getUserManager(), |
|
102 | - $this->serverContainer->getGroupManager(), |
|
103 | - $this->serverContainer->getLazyRootFolder(), |
|
104 | - $this->serverContainer->getMailer(), |
|
105 | - $this->serverContainer->query(Defaults::class), |
|
106 | - $this->serverContainer->getL10NFactory(), |
|
107 | - $this->serverContainer->getURLGenerator(), |
|
108 | - $this->serverContainer->getConfig() |
|
109 | - ); |
|
110 | - } |
|
111 | - |
|
112 | - return $this->defaultProvider; |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * Create the federated share provider |
|
117 | - * |
|
118 | - * @return FederatedShareProvider |
|
119 | - */ |
|
120 | - protected function federatedShareProvider() { |
|
121 | - if ($this->federatedProvider === null) { |
|
122 | - /* |
|
60 | + /** @var IServerContainer */ |
|
61 | + private $serverContainer; |
|
62 | + /** @var DefaultShareProvider */ |
|
63 | + private $defaultProvider = null; |
|
64 | + /** @var FederatedShareProvider */ |
|
65 | + private $federatedProvider = null; |
|
66 | + /** @var ShareByMailProvider */ |
|
67 | + private $shareByMailProvider; |
|
68 | + /** @var \OCA\Circles\ShareByCircleProvider */ |
|
69 | + private $shareByCircleProvider = null; |
|
70 | + /** @var bool */ |
|
71 | + private $circlesAreNotAvailable = false; |
|
72 | + /** @var \OCA\Talk\Share\RoomShareProvider */ |
|
73 | + private $roomShareProvider = null; |
|
74 | + |
|
75 | + private $registeredShareProviders = []; |
|
76 | + |
|
77 | + private $shareProviders = []; |
|
78 | + |
|
79 | + /** |
|
80 | + * IProviderFactory constructor. |
|
81 | + * |
|
82 | + * @param IServerContainer $serverContainer |
|
83 | + */ |
|
84 | + public function __construct(IServerContainer $serverContainer) { |
|
85 | + $this->serverContainer = $serverContainer; |
|
86 | + } |
|
87 | + |
|
88 | + public function registerProvider(string $shareProviderClass): void { |
|
89 | + $this->registeredShareProviders[] = $shareProviderClass; |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * Create the default share provider. |
|
94 | + * |
|
95 | + * @return DefaultShareProvider |
|
96 | + */ |
|
97 | + protected function defaultShareProvider() { |
|
98 | + if ($this->defaultProvider === null) { |
|
99 | + $this->defaultProvider = new DefaultShareProvider( |
|
100 | + $this->serverContainer->getDatabaseConnection(), |
|
101 | + $this->serverContainer->getUserManager(), |
|
102 | + $this->serverContainer->getGroupManager(), |
|
103 | + $this->serverContainer->getLazyRootFolder(), |
|
104 | + $this->serverContainer->getMailer(), |
|
105 | + $this->serverContainer->query(Defaults::class), |
|
106 | + $this->serverContainer->getL10NFactory(), |
|
107 | + $this->serverContainer->getURLGenerator(), |
|
108 | + $this->serverContainer->getConfig() |
|
109 | + ); |
|
110 | + } |
|
111 | + |
|
112 | + return $this->defaultProvider; |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * Create the federated share provider |
|
117 | + * |
|
118 | + * @return FederatedShareProvider |
|
119 | + */ |
|
120 | + protected function federatedShareProvider() { |
|
121 | + if ($this->federatedProvider === null) { |
|
122 | + /* |
|
123 | 123 | * Check if the app is enabled |
124 | 124 | */ |
125 | - $appManager = $this->serverContainer->getAppManager(); |
|
126 | - if (!$appManager->isEnabledForUser('federatedfilesharing')) { |
|
127 | - return null; |
|
128 | - } |
|
125 | + $appManager = $this->serverContainer->getAppManager(); |
|
126 | + if (!$appManager->isEnabledForUser('federatedfilesharing')) { |
|
127 | + return null; |
|
128 | + } |
|
129 | 129 | |
130 | - /* |
|
130 | + /* |
|
131 | 131 | * TODO: add factory to federated sharing app |
132 | 132 | */ |
133 | - $l = $this->serverContainer->getL10N('federatedfilesharing'); |
|
134 | - $addressHandler = new AddressHandler( |
|
135 | - $this->serverContainer->getURLGenerator(), |
|
136 | - $l, |
|
137 | - $this->serverContainer->getCloudIdManager() |
|
138 | - ); |
|
139 | - $notifications = new Notifications( |
|
140 | - $addressHandler, |
|
141 | - $this->serverContainer->getHTTPClientService(), |
|
142 | - $this->serverContainer->query(\OCP\OCS\IDiscoveryService::class), |
|
143 | - $this->serverContainer->getLogger(), |
|
144 | - $this->serverContainer->getJobList(), |
|
145 | - \OC::$server->getCloudFederationProviderManager(), |
|
146 | - \OC::$server->getCloudFederationFactory(), |
|
147 | - $this->serverContainer->query(IEventDispatcher::class) |
|
148 | - ); |
|
149 | - $tokenHandler = new TokenHandler( |
|
150 | - $this->serverContainer->getSecureRandom() |
|
151 | - ); |
|
152 | - |
|
153 | - $this->federatedProvider = new FederatedShareProvider( |
|
154 | - $this->serverContainer->getDatabaseConnection(), |
|
155 | - $addressHandler, |
|
156 | - $notifications, |
|
157 | - $tokenHandler, |
|
158 | - $l, |
|
159 | - $this->serverContainer->getLogger(), |
|
160 | - $this->serverContainer->getLazyRootFolder(), |
|
161 | - $this->serverContainer->getConfig(), |
|
162 | - $this->serverContainer->getUserManager(), |
|
163 | - $this->serverContainer->getCloudIdManager(), |
|
164 | - $this->serverContainer->getGlobalScaleConfig(), |
|
165 | - $this->serverContainer->getCloudFederationProviderManager() |
|
166 | - ); |
|
167 | - } |
|
168 | - |
|
169 | - return $this->federatedProvider; |
|
170 | - } |
|
171 | - |
|
172 | - /** |
|
173 | - * Create the federated share provider |
|
174 | - * |
|
175 | - * @return ShareByMailProvider |
|
176 | - */ |
|
177 | - protected function getShareByMailProvider() { |
|
178 | - if ($this->shareByMailProvider === null) { |
|
179 | - /* |
|
133 | + $l = $this->serverContainer->getL10N('federatedfilesharing'); |
|
134 | + $addressHandler = new AddressHandler( |
|
135 | + $this->serverContainer->getURLGenerator(), |
|
136 | + $l, |
|
137 | + $this->serverContainer->getCloudIdManager() |
|
138 | + ); |
|
139 | + $notifications = new Notifications( |
|
140 | + $addressHandler, |
|
141 | + $this->serverContainer->getHTTPClientService(), |
|
142 | + $this->serverContainer->query(\OCP\OCS\IDiscoveryService::class), |
|
143 | + $this->serverContainer->getLogger(), |
|
144 | + $this->serverContainer->getJobList(), |
|
145 | + \OC::$server->getCloudFederationProviderManager(), |
|
146 | + \OC::$server->getCloudFederationFactory(), |
|
147 | + $this->serverContainer->query(IEventDispatcher::class) |
|
148 | + ); |
|
149 | + $tokenHandler = new TokenHandler( |
|
150 | + $this->serverContainer->getSecureRandom() |
|
151 | + ); |
|
152 | + |
|
153 | + $this->federatedProvider = new FederatedShareProvider( |
|
154 | + $this->serverContainer->getDatabaseConnection(), |
|
155 | + $addressHandler, |
|
156 | + $notifications, |
|
157 | + $tokenHandler, |
|
158 | + $l, |
|
159 | + $this->serverContainer->getLogger(), |
|
160 | + $this->serverContainer->getLazyRootFolder(), |
|
161 | + $this->serverContainer->getConfig(), |
|
162 | + $this->serverContainer->getUserManager(), |
|
163 | + $this->serverContainer->getCloudIdManager(), |
|
164 | + $this->serverContainer->getGlobalScaleConfig(), |
|
165 | + $this->serverContainer->getCloudFederationProviderManager() |
|
166 | + ); |
|
167 | + } |
|
168 | + |
|
169 | + return $this->federatedProvider; |
|
170 | + } |
|
171 | + |
|
172 | + /** |
|
173 | + * Create the federated share provider |
|
174 | + * |
|
175 | + * @return ShareByMailProvider |
|
176 | + */ |
|
177 | + protected function getShareByMailProvider() { |
|
178 | + if ($this->shareByMailProvider === null) { |
|
179 | + /* |
|
180 | 180 | * Check if the app is enabled |
181 | 181 | */ |
182 | - $appManager = $this->serverContainer->getAppManager(); |
|
183 | - if (!$appManager->isEnabledForUser('sharebymail')) { |
|
184 | - return null; |
|
185 | - } |
|
186 | - |
|
187 | - $settingsManager = new SettingsManager($this->serverContainer->getConfig()); |
|
188 | - |
|
189 | - $this->shareByMailProvider = new ShareByMailProvider( |
|
190 | - $this->serverContainer->getConfig(), |
|
191 | - $this->serverContainer->getDatabaseConnection(), |
|
192 | - $this->serverContainer->getSecureRandom(), |
|
193 | - $this->serverContainer->getUserManager(), |
|
194 | - $this->serverContainer->getLazyRootFolder(), |
|
195 | - $this->serverContainer->getL10N('sharebymail'), |
|
196 | - $this->serverContainer->getLogger(), |
|
197 | - $this->serverContainer->getMailer(), |
|
198 | - $this->serverContainer->getURLGenerator(), |
|
199 | - $this->serverContainer->getActivityManager(), |
|
200 | - $settingsManager, |
|
201 | - $this->serverContainer->query(Defaults::class), |
|
202 | - $this->serverContainer->getHasher(), |
|
203 | - $this->serverContainer->get(IEventDispatcher::class), |
|
204 | - $this->serverContainer->get(IManager::class) |
|
205 | - ); |
|
206 | - } |
|
207 | - |
|
208 | - return $this->shareByMailProvider; |
|
209 | - } |
|
210 | - |
|
211 | - |
|
212 | - /** |
|
213 | - * Create the circle share provider |
|
214 | - * |
|
215 | - * @return FederatedShareProvider |
|
216 | - * |
|
217 | - * @suppress PhanUndeclaredClassMethod |
|
218 | - */ |
|
219 | - protected function getShareByCircleProvider() { |
|
220 | - if ($this->circlesAreNotAvailable) { |
|
221 | - return null; |
|
222 | - } |
|
223 | - |
|
224 | - if (!$this->serverContainer->getAppManager()->isEnabledForUser('circles') || |
|
225 | - !class_exists('\OCA\Circles\ShareByCircleProvider') |
|
226 | - ) { |
|
227 | - $this->circlesAreNotAvailable = true; |
|
228 | - return null; |
|
229 | - } |
|
230 | - |
|
231 | - if ($this->shareByCircleProvider === null) { |
|
232 | - $this->shareByCircleProvider = new \OCA\Circles\ShareByCircleProvider( |
|
233 | - $this->serverContainer->getDatabaseConnection(), |
|
234 | - $this->serverContainer->getSecureRandom(), |
|
235 | - $this->serverContainer->getUserManager(), |
|
236 | - $this->serverContainer->getLazyRootFolder(), |
|
237 | - $this->serverContainer->getL10N('circles'), |
|
238 | - $this->serverContainer->getLogger(), |
|
239 | - $this->serverContainer->getURLGenerator() |
|
240 | - ); |
|
241 | - } |
|
242 | - |
|
243 | - return $this->shareByCircleProvider; |
|
244 | - } |
|
245 | - |
|
246 | - /** |
|
247 | - * Create the room share provider |
|
248 | - * |
|
249 | - * @return RoomShareProvider |
|
250 | - */ |
|
251 | - protected function getRoomShareProvider() { |
|
252 | - if ($this->roomShareProvider === null) { |
|
253 | - /* |
|
182 | + $appManager = $this->serverContainer->getAppManager(); |
|
183 | + if (!$appManager->isEnabledForUser('sharebymail')) { |
|
184 | + return null; |
|
185 | + } |
|
186 | + |
|
187 | + $settingsManager = new SettingsManager($this->serverContainer->getConfig()); |
|
188 | + |
|
189 | + $this->shareByMailProvider = new ShareByMailProvider( |
|
190 | + $this->serverContainer->getConfig(), |
|
191 | + $this->serverContainer->getDatabaseConnection(), |
|
192 | + $this->serverContainer->getSecureRandom(), |
|
193 | + $this->serverContainer->getUserManager(), |
|
194 | + $this->serverContainer->getLazyRootFolder(), |
|
195 | + $this->serverContainer->getL10N('sharebymail'), |
|
196 | + $this->serverContainer->getLogger(), |
|
197 | + $this->serverContainer->getMailer(), |
|
198 | + $this->serverContainer->getURLGenerator(), |
|
199 | + $this->serverContainer->getActivityManager(), |
|
200 | + $settingsManager, |
|
201 | + $this->serverContainer->query(Defaults::class), |
|
202 | + $this->serverContainer->getHasher(), |
|
203 | + $this->serverContainer->get(IEventDispatcher::class), |
|
204 | + $this->serverContainer->get(IManager::class) |
|
205 | + ); |
|
206 | + } |
|
207 | + |
|
208 | + return $this->shareByMailProvider; |
|
209 | + } |
|
210 | + |
|
211 | + |
|
212 | + /** |
|
213 | + * Create the circle share provider |
|
214 | + * |
|
215 | + * @return FederatedShareProvider |
|
216 | + * |
|
217 | + * @suppress PhanUndeclaredClassMethod |
|
218 | + */ |
|
219 | + protected function getShareByCircleProvider() { |
|
220 | + if ($this->circlesAreNotAvailable) { |
|
221 | + return null; |
|
222 | + } |
|
223 | + |
|
224 | + if (!$this->serverContainer->getAppManager()->isEnabledForUser('circles') || |
|
225 | + !class_exists('\OCA\Circles\ShareByCircleProvider') |
|
226 | + ) { |
|
227 | + $this->circlesAreNotAvailable = true; |
|
228 | + return null; |
|
229 | + } |
|
230 | + |
|
231 | + if ($this->shareByCircleProvider === null) { |
|
232 | + $this->shareByCircleProvider = new \OCA\Circles\ShareByCircleProvider( |
|
233 | + $this->serverContainer->getDatabaseConnection(), |
|
234 | + $this->serverContainer->getSecureRandom(), |
|
235 | + $this->serverContainer->getUserManager(), |
|
236 | + $this->serverContainer->getLazyRootFolder(), |
|
237 | + $this->serverContainer->getL10N('circles'), |
|
238 | + $this->serverContainer->getLogger(), |
|
239 | + $this->serverContainer->getURLGenerator() |
|
240 | + ); |
|
241 | + } |
|
242 | + |
|
243 | + return $this->shareByCircleProvider; |
|
244 | + } |
|
245 | + |
|
246 | + /** |
|
247 | + * Create the room share provider |
|
248 | + * |
|
249 | + * @return RoomShareProvider |
|
250 | + */ |
|
251 | + protected function getRoomShareProvider() { |
|
252 | + if ($this->roomShareProvider === null) { |
|
253 | + /* |
|
254 | 254 | * Check if the app is enabled |
255 | 255 | */ |
256 | - $appManager = $this->serverContainer->getAppManager(); |
|
257 | - if (!$appManager->isEnabledForUser('spreed')) { |
|
258 | - return null; |
|
259 | - } |
|
260 | - |
|
261 | - try { |
|
262 | - /** |
|
263 | - * @psalm-suppress UndefinedClass |
|
264 | - */ |
|
265 | - $this->roomShareProvider = $this->serverContainer->get(RoomShareProvider::class); |
|
266 | - } catch (\Throwable $e) { |
|
267 | - $this->serverContainer->get(LoggerInterface::class)->error( |
|
268 | - $e->getMessage(), |
|
269 | - ['exception' => $e] |
|
270 | - ); |
|
271 | - return null; |
|
272 | - } |
|
273 | - } |
|
274 | - |
|
275 | - return $this->roomShareProvider; |
|
276 | - } |
|
277 | - |
|
278 | - /** |
|
279 | - * @inheritdoc |
|
280 | - */ |
|
281 | - public function getProvider($id) { |
|
282 | - $provider = null; |
|
283 | - if (isset($this->shareProviders[$id])) { |
|
284 | - return $this->shareProviders[$id]; |
|
285 | - } |
|
286 | - |
|
287 | - if ($id === 'ocinternal') { |
|
288 | - $provider = $this->defaultShareProvider(); |
|
289 | - } elseif ($id === 'ocFederatedSharing') { |
|
290 | - $provider = $this->federatedShareProvider(); |
|
291 | - } elseif ($id === 'ocMailShare') { |
|
292 | - $provider = $this->getShareByMailProvider(); |
|
293 | - } elseif ($id === 'ocCircleShare') { |
|
294 | - $provider = $this->getShareByCircleProvider(); |
|
295 | - } elseif ($id === 'ocRoomShare') { |
|
296 | - $provider = $this->getRoomShareProvider(); |
|
297 | - } |
|
298 | - |
|
299 | - foreach ($this->registeredShareProviders as $shareProvider) { |
|
300 | - try { |
|
301 | - /** @var IShareProvider $instance */ |
|
302 | - $instance = $this->serverContainer->get($shareProvider); |
|
303 | - $this->shareProviders[$instance->identifier()] = $instance; |
|
304 | - } catch (\Throwable $e) { |
|
305 | - $this->serverContainer->get(LoggerInterface::class)->error( |
|
306 | - $e->getMessage(), |
|
307 | - ['exception' => $e] |
|
308 | - ); |
|
309 | - } |
|
310 | - } |
|
311 | - |
|
312 | - if (isset($this->shareProviders[$id])) { |
|
313 | - $provider = $this->shareProviders[$id]; |
|
314 | - } |
|
315 | - |
|
316 | - if ($provider === null) { |
|
317 | - throw new ProviderException('No provider with id .' . $id . ' found.'); |
|
318 | - } |
|
319 | - |
|
320 | - return $provider; |
|
321 | - } |
|
322 | - |
|
323 | - /** |
|
324 | - * @inheritdoc |
|
325 | - */ |
|
326 | - public function getProviderForType($shareType) { |
|
327 | - $provider = null; |
|
328 | - |
|
329 | - if ($shareType === IShare::TYPE_USER || |
|
330 | - $shareType === IShare::TYPE_GROUP || |
|
331 | - $shareType === IShare::TYPE_LINK |
|
332 | - ) { |
|
333 | - $provider = $this->defaultShareProvider(); |
|
334 | - } elseif ($shareType === IShare::TYPE_REMOTE || $shareType === IShare::TYPE_REMOTE_GROUP) { |
|
335 | - $provider = $this->federatedShareProvider(); |
|
336 | - } elseif ($shareType === IShare::TYPE_EMAIL) { |
|
337 | - $provider = $this->getShareByMailProvider(); |
|
338 | - } elseif ($shareType === IShare::TYPE_CIRCLE) { |
|
339 | - $provider = $this->getShareByCircleProvider(); |
|
340 | - } elseif ($shareType === IShare::TYPE_ROOM) { |
|
341 | - $provider = $this->getRoomShareProvider(); |
|
342 | - } elseif ($shareType === IShare::TYPE_DECK) { |
|
343 | - $provider = $this->getProvider('deck'); |
|
344 | - } |
|
345 | - |
|
346 | - |
|
347 | - if ($provider === null) { |
|
348 | - throw new ProviderException('No share provider for share type ' . $shareType); |
|
349 | - } |
|
350 | - |
|
351 | - return $provider; |
|
352 | - } |
|
353 | - |
|
354 | - public function getAllProviders() { |
|
355 | - $shares = [$this->defaultShareProvider(), $this->federatedShareProvider()]; |
|
356 | - $shareByMail = $this->getShareByMailProvider(); |
|
357 | - if ($shareByMail !== null) { |
|
358 | - $shares[] = $shareByMail; |
|
359 | - } |
|
360 | - $shareByCircle = $this->getShareByCircleProvider(); |
|
361 | - if ($shareByCircle !== null) { |
|
362 | - $shares[] = $shareByCircle; |
|
363 | - } |
|
364 | - $roomShare = $this->getRoomShareProvider(); |
|
365 | - if ($roomShare !== null) { |
|
366 | - $shares[] = $roomShare; |
|
367 | - } |
|
368 | - |
|
369 | - foreach ($this->registeredShareProviders as $shareProvider) { |
|
370 | - try { |
|
371 | - /** @var IShareProvider $instance */ |
|
372 | - $instance = $this->serverContainer->get($shareProvider); |
|
373 | - } catch (\Throwable $e) { |
|
374 | - $this->serverContainer->get(LoggerInterface::class)->error( |
|
375 | - $e->getMessage(), |
|
376 | - ['exception' => $e] |
|
377 | - ); |
|
378 | - continue; |
|
379 | - } |
|
380 | - |
|
381 | - if (!isset($this->shareProviders[$instance->identifier()])) { |
|
382 | - $this->shareProviders[$instance->identifier()] = $instance; |
|
383 | - } |
|
384 | - $shares[] = $this->shareProviders[$instance->identifier()]; |
|
385 | - } |
|
386 | - |
|
387 | - |
|
388 | - |
|
389 | - return $shares; |
|
390 | - } |
|
256 | + $appManager = $this->serverContainer->getAppManager(); |
|
257 | + if (!$appManager->isEnabledForUser('spreed')) { |
|
258 | + return null; |
|
259 | + } |
|
260 | + |
|
261 | + try { |
|
262 | + /** |
|
263 | + * @psalm-suppress UndefinedClass |
|
264 | + */ |
|
265 | + $this->roomShareProvider = $this->serverContainer->get(RoomShareProvider::class); |
|
266 | + } catch (\Throwable $e) { |
|
267 | + $this->serverContainer->get(LoggerInterface::class)->error( |
|
268 | + $e->getMessage(), |
|
269 | + ['exception' => $e] |
|
270 | + ); |
|
271 | + return null; |
|
272 | + } |
|
273 | + } |
|
274 | + |
|
275 | + return $this->roomShareProvider; |
|
276 | + } |
|
277 | + |
|
278 | + /** |
|
279 | + * @inheritdoc |
|
280 | + */ |
|
281 | + public function getProvider($id) { |
|
282 | + $provider = null; |
|
283 | + if (isset($this->shareProviders[$id])) { |
|
284 | + return $this->shareProviders[$id]; |
|
285 | + } |
|
286 | + |
|
287 | + if ($id === 'ocinternal') { |
|
288 | + $provider = $this->defaultShareProvider(); |
|
289 | + } elseif ($id === 'ocFederatedSharing') { |
|
290 | + $provider = $this->federatedShareProvider(); |
|
291 | + } elseif ($id === 'ocMailShare') { |
|
292 | + $provider = $this->getShareByMailProvider(); |
|
293 | + } elseif ($id === 'ocCircleShare') { |
|
294 | + $provider = $this->getShareByCircleProvider(); |
|
295 | + } elseif ($id === 'ocRoomShare') { |
|
296 | + $provider = $this->getRoomShareProvider(); |
|
297 | + } |
|
298 | + |
|
299 | + foreach ($this->registeredShareProviders as $shareProvider) { |
|
300 | + try { |
|
301 | + /** @var IShareProvider $instance */ |
|
302 | + $instance = $this->serverContainer->get($shareProvider); |
|
303 | + $this->shareProviders[$instance->identifier()] = $instance; |
|
304 | + } catch (\Throwable $e) { |
|
305 | + $this->serverContainer->get(LoggerInterface::class)->error( |
|
306 | + $e->getMessage(), |
|
307 | + ['exception' => $e] |
|
308 | + ); |
|
309 | + } |
|
310 | + } |
|
311 | + |
|
312 | + if (isset($this->shareProviders[$id])) { |
|
313 | + $provider = $this->shareProviders[$id]; |
|
314 | + } |
|
315 | + |
|
316 | + if ($provider === null) { |
|
317 | + throw new ProviderException('No provider with id .' . $id . ' found.'); |
|
318 | + } |
|
319 | + |
|
320 | + return $provider; |
|
321 | + } |
|
322 | + |
|
323 | + /** |
|
324 | + * @inheritdoc |
|
325 | + */ |
|
326 | + public function getProviderForType($shareType) { |
|
327 | + $provider = null; |
|
328 | + |
|
329 | + if ($shareType === IShare::TYPE_USER || |
|
330 | + $shareType === IShare::TYPE_GROUP || |
|
331 | + $shareType === IShare::TYPE_LINK |
|
332 | + ) { |
|
333 | + $provider = $this->defaultShareProvider(); |
|
334 | + } elseif ($shareType === IShare::TYPE_REMOTE || $shareType === IShare::TYPE_REMOTE_GROUP) { |
|
335 | + $provider = $this->federatedShareProvider(); |
|
336 | + } elseif ($shareType === IShare::TYPE_EMAIL) { |
|
337 | + $provider = $this->getShareByMailProvider(); |
|
338 | + } elseif ($shareType === IShare::TYPE_CIRCLE) { |
|
339 | + $provider = $this->getShareByCircleProvider(); |
|
340 | + } elseif ($shareType === IShare::TYPE_ROOM) { |
|
341 | + $provider = $this->getRoomShareProvider(); |
|
342 | + } elseif ($shareType === IShare::TYPE_DECK) { |
|
343 | + $provider = $this->getProvider('deck'); |
|
344 | + } |
|
345 | + |
|
346 | + |
|
347 | + if ($provider === null) { |
|
348 | + throw new ProviderException('No share provider for share type ' . $shareType); |
|
349 | + } |
|
350 | + |
|
351 | + return $provider; |
|
352 | + } |
|
353 | + |
|
354 | + public function getAllProviders() { |
|
355 | + $shares = [$this->defaultShareProvider(), $this->federatedShareProvider()]; |
|
356 | + $shareByMail = $this->getShareByMailProvider(); |
|
357 | + if ($shareByMail !== null) { |
|
358 | + $shares[] = $shareByMail; |
|
359 | + } |
|
360 | + $shareByCircle = $this->getShareByCircleProvider(); |
|
361 | + if ($shareByCircle !== null) { |
|
362 | + $shares[] = $shareByCircle; |
|
363 | + } |
|
364 | + $roomShare = $this->getRoomShareProvider(); |
|
365 | + if ($roomShare !== null) { |
|
366 | + $shares[] = $roomShare; |
|
367 | + } |
|
368 | + |
|
369 | + foreach ($this->registeredShareProviders as $shareProvider) { |
|
370 | + try { |
|
371 | + /** @var IShareProvider $instance */ |
|
372 | + $instance = $this->serverContainer->get($shareProvider); |
|
373 | + } catch (\Throwable $e) { |
|
374 | + $this->serverContainer->get(LoggerInterface::class)->error( |
|
375 | + $e->getMessage(), |
|
376 | + ['exception' => $e] |
|
377 | + ); |
|
378 | + continue; |
|
379 | + } |
|
380 | + |
|
381 | + if (!isset($this->shareProviders[$instance->identifier()])) { |
|
382 | + $this->shareProviders[$instance->identifier()] = $instance; |
|
383 | + } |
|
384 | + $shares[] = $this->shareProviders[$instance->identifier()]; |
|
385 | + } |
|
386 | + |
|
387 | + |
|
388 | + |
|
389 | + return $shares; |
|
390 | + } |
|
391 | 391 | } |
@@ -37,57 +37,57 @@ |
||
37 | 37 | */ |
38 | 38 | class ConsoleOutput implements IOutput { |
39 | 39 | |
40 | - /** @var OutputInterface */ |
|
41 | - private $output; |
|
40 | + /** @var OutputInterface */ |
|
41 | + private $output; |
|
42 | 42 | |
43 | - /** @var ProgressBar */ |
|
44 | - private $progressBar; |
|
43 | + /** @var ProgressBar */ |
|
44 | + private $progressBar; |
|
45 | 45 | |
46 | - public function __construct(OutputInterface $output) { |
|
47 | - $this->output = $output; |
|
48 | - } |
|
46 | + public function __construct(OutputInterface $output) { |
|
47 | + $this->output = $output; |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * @param string $message |
|
52 | - */ |
|
53 | - public function info($message) { |
|
54 | - $this->output->writeln("<info>$message</info>"); |
|
55 | - } |
|
50 | + /** |
|
51 | + * @param string $message |
|
52 | + */ |
|
53 | + public function info($message) { |
|
54 | + $this->output->writeln("<info>$message</info>"); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * @param string $message |
|
59 | - */ |
|
60 | - public function warning($message) { |
|
61 | - $this->output->writeln("<comment>$message</comment>"); |
|
62 | - } |
|
57 | + /** |
|
58 | + * @param string $message |
|
59 | + */ |
|
60 | + public function warning($message) { |
|
61 | + $this->output->writeln("<comment>$message</comment>"); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @param int $max |
|
66 | - */ |
|
67 | - public function startProgress($max = 0) { |
|
68 | - if (!is_null($this->progressBar)) { |
|
69 | - $this->progressBar->finish(); |
|
70 | - } |
|
71 | - $this->progressBar = new ProgressBar($this->output); |
|
72 | - $this->progressBar->start($max); |
|
73 | - } |
|
64 | + /** |
|
65 | + * @param int $max |
|
66 | + */ |
|
67 | + public function startProgress($max = 0) { |
|
68 | + if (!is_null($this->progressBar)) { |
|
69 | + $this->progressBar->finish(); |
|
70 | + } |
|
71 | + $this->progressBar = new ProgressBar($this->output); |
|
72 | + $this->progressBar->start($max); |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * @param int $step |
|
77 | - * @param string $description |
|
78 | - */ |
|
79 | - public function advance($step = 1, $description = '') { |
|
80 | - if (!is_null($this->progressBar)) { |
|
81 | - $this->progressBar = new ProgressBar($this->output); |
|
82 | - $this->progressBar->start(); |
|
83 | - } |
|
84 | - $this->progressBar->advance($step); |
|
85 | - } |
|
75 | + /** |
|
76 | + * @param int $step |
|
77 | + * @param string $description |
|
78 | + */ |
|
79 | + public function advance($step = 1, $description = '') { |
|
80 | + if (!is_null($this->progressBar)) { |
|
81 | + $this->progressBar = new ProgressBar($this->output); |
|
82 | + $this->progressBar->start(); |
|
83 | + } |
|
84 | + $this->progressBar->advance($step); |
|
85 | + } |
|
86 | 86 | |
87 | - public function finishProgress() { |
|
88 | - if (is_null($this->progressBar)) { |
|
89 | - return; |
|
90 | - } |
|
91 | - $this->progressBar->finish(); |
|
92 | - } |
|
87 | + public function finishProgress() { |
|
88 | + if (is_null($this->progressBar)) { |
|
89 | + return; |
|
90 | + } |
|
91 | + $this->progressBar->finish(); |
|
92 | + } |
|
93 | 93 | } |
@@ -7,23 +7,23 @@ |
||
7 | 7 | |
8 | 8 | class RootCollection extends AbstractPrincipalCollection { |
9 | 9 | |
10 | - /** |
|
11 | - * This method returns a node for a principal. |
|
12 | - * |
|
13 | - * The passed array contains principal information, and is guaranteed to |
|
14 | - * at least contain a uri item. Other properties may or may not be |
|
15 | - * supplied by the authentication backend. |
|
16 | - * |
|
17 | - * @param array $principalInfo |
|
18 | - * @return AvatarHome |
|
19 | - */ |
|
20 | - public function getChildForPrincipal(array $principalInfo) { |
|
21 | - $avatarManager = \OC::$server->getAvatarManager(); |
|
22 | - return new AvatarHome($principalInfo, $avatarManager); |
|
23 | - } |
|
10 | + /** |
|
11 | + * This method returns a node for a principal. |
|
12 | + * |
|
13 | + * The passed array contains principal information, and is guaranteed to |
|
14 | + * at least contain a uri item. Other properties may or may not be |
|
15 | + * supplied by the authentication backend. |
|
16 | + * |
|
17 | + * @param array $principalInfo |
|
18 | + * @return AvatarHome |
|
19 | + */ |
|
20 | + public function getChildForPrincipal(array $principalInfo) { |
|
21 | + $avatarManager = \OC::$server->getAvatarManager(); |
|
22 | + return new AvatarHome($principalInfo, $avatarManager); |
|
23 | + } |
|
24 | 24 | |
25 | - public function getName() { |
|
26 | - return 'avatars'; |
|
27 | - } |
|
25 | + public function getName() { |
|
26 | + return 'avatars'; |
|
27 | + } |
|
28 | 28 | |
29 | 29 | } |