-
Notifications
You must be signed in to change notification settings - Fork 428
Expand file tree
/
Copy pathRegisterDeferredCommands.php
More file actions
54 lines (45 loc) · 1.2 KB
/
RegisterDeferredCommands.php
File metadata and controls
54 lines (45 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
namespace EE\Bootstrap;
use EE;
/**
* Class RegisterDeferredCommands.
*
* Registers the deferred commands that for which no parent was registered yet.
* This is necessary, because we can have sub-commands that have no direct
* parent.
*
* @package EE\Bootstrap
*/
final class RegisterDeferredCommands implements BootstrapStep {
/**
* Process this single bootstrapping step.
*
* @param BootstrapState $state Contextual state to pass into the step.
*
* @return BootstrapState Modified state to pass to the next step.
*/
public function process( BootstrapState $state ) {
// Process deferred command additions for external packages.
$this->add_deferred_commands();
// Process deferred command additions for commands added through
// plugins.
EE::add_hook(
'find_command_to_run_pre',
array( $this, 'add_deferred_commands' )
);
return $state;
}
/**
* Add deferred commands that are still waiting to be processed.
*/
public function add_deferred_commands() {
$deferred_additions = EE::get_deferred_additions();
foreach ( $deferred_additions as $name => $addition ) {
EE::add_command(
$name,
$addition['callable'],
$addition['args']
);
}
}
}