|
124 | 124 | * OC\Console\Application::loadCommands). |
125 | 125 | * |
126 | 126 | * TODO (maybe): |
127 | | - * - Refactor this into a real class/service provider w/ clear dependency handling/etc. |
128 | | - * - Make each core command a tagged service and have the container or a service aggregator auto-register them. |
| 127 | + * - Refactor this into a real class/service/callable w/ clear dependency handling/etc. |
| 128 | + * - Make each core command a tagged service and have the container or a service aggregator |
| 129 | + * auto-register them. |
129 | 130 | */ |
130 | 131 |
|
131 | | -$config = Server::get(IConfig::class); |
132 | | - |
133 | | -// State lifecycle flags |
134 | | -$installed = $config->getSystemValueBool('installed', false); |
135 | | -$maintenance = $installed && $config->getSystemValueBool('maintenance', false); |
136 | | -$needUpgrade = $installed && \OCP\Util::needUpgrade(); |
137 | | -$debug = $config->getSystemValueBool('debug', false); |
| 132 | +// These variables are expected to be provided by the including scope (Application::loadCommands) |
| 133 | +/** @var \Symfony\Component\Console\Application $application */ |
| 134 | +/** @var bool $installed */ |
| 135 | +/** @var bool $maintenance */ |
| 136 | +/** @var bool $needUpgrade */ |
| 137 | +/** @var bool $debug */ |
138 | 138 |
|
139 | 139 | /* |
140 | | - * Commands that should always be registered. |
141 | | - * |
142 | | - * In addition availability in normal operating mode, these commands are to be available: |
143 | | - * - pre-install |
144 | | - * - in maintenance mode |
145 | | - * - when an upgrade is needed |
| 140 | + * Commands that should always be registered (i.e. normal, pre-install, maintenance, upgrade needed) |
146 | 141 | */ |
147 | 142 | $alwaysCommands = [ |
148 | 143 | CompletionCommand::class, |
|
158 | 153 | ]; |
159 | 154 |
|
160 | 155 | /* |
161 | | - * Commands required when an upgrade is needed (besides _completion) |
| 156 | + * Commands required when an upgrade is needed (besides above) |
162 | 157 | */ |
163 | 158 | $upgradeCommands = [ |
164 | 159 | Command\Maintenance\Mode::class, |
165 | 160 | Upgrade::class, |
166 | 161 | ]; |
167 | 162 |
|
168 | 163 | /* |
169 | | - * Commands available only when not installed (installer) |
| 164 | + * Commands available only when not installed |
170 | 165 | */ |
171 | 166 | $installerCommands = [ |
172 | 167 | Command\Maintenance\Install::class, |
173 | 168 | ]; |
174 | 169 |
|
175 | 170 | /* |
176 | | - * Small set of commands allowed in maintenance mode (no apps loaded) |
| 171 | + * Commands allowed in maintenance mode (no apps loaded) |
177 | 172 | */ |
178 | 173 | $maintenanceCommands = [ |
179 | 174 | Command\Maintenance\Mode::class, |
180 | 175 | ]; |
181 | 176 |
|
182 | 177 | /* |
183 | | - * Commands for a normal installed instance |
| 178 | + * Commands for normal (installed/up-to-date/non-maintenance) operating mode |
184 | 179 | */ |
185 | 180 | $installedCommands = [ |
186 | 181 | // "app" |
|
358 | 353 | StatusCommand::class, |
359 | 354 | ]; |
360 | 355 |
|
361 | | -/** @var \Symfony\Component\Console\Application $application */ |
362 | | - |
363 | | -// Helper to resolve & add a list of command classes. |
| 356 | +/** |
| 357 | + * Helper to resolve & add a list of command classes. |
| 358 | + * |
| 359 | + * Will abort registering if any app/service fails to load. |
| 360 | + * |
| 361 | + */ |
364 | 362 | $addCommands = function (array $classes) use ($application) { |
365 | 363 | foreach ($classes as $class) { |
366 | 364 | // CompletionCommand is instantiated directly (not resolved from container). |
|
0 commit comments