Skip to content

Commit 47cc2df

Browse files
chore(core): additional register_command tidying
Updated comments for clarity and consistency. Signed-off-by: Josh <[email protected]>
1 parent d01f768 commit 47cc2df

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

core/register_command.php

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -124,25 +124,20 @@
124124
* OC\Console\Application::loadCommands).
125125
*
126126
* 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.
129130
*/
130131

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 */
138138

139139
/*
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)
146141
*/
147142
$alwaysCommands = [
148143
CompletionCommand::class,
@@ -158,29 +153,29 @@
158153
];
159154

160155
/*
161-
* Commands required when an upgrade is needed (besides _completion)
156+
* Commands required when an upgrade is needed (besides above)
162157
*/
163158
$upgradeCommands = [
164159
Command\Maintenance\Mode::class,
165160
Upgrade::class,
166161
];
167162

168163
/*
169-
* Commands available only when not installed (installer)
164+
* Commands available only when not installed
170165
*/
171166
$installerCommands = [
172167
Command\Maintenance\Install::class,
173168
];
174169

175170
/*
176-
* Small set of commands allowed in maintenance mode (no apps loaded)
171+
* Commands allowed in maintenance mode (no apps loaded)
177172
*/
178173
$maintenanceCommands = [
179174
Command\Maintenance\Mode::class,
180175
];
181176

182177
/*
183-
* Commands for a normal installed instance
178+
* Commands for normal (installed/up-to-date/non-maintenance) operating mode
184179
*/
185180
$installedCommands = [
186181
// "app"
@@ -358,9 +353,12 @@
358353
StatusCommand::class,
359354
];
360355

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+
*/
364362
$addCommands = function (array $classes) use ($application) {
365363
foreach ($classes as $class) {
366364
// CompletionCommand is instantiated directly (not resolved from container).

0 commit comments

Comments
 (0)