-
Notifications
You must be signed in to change notification settings - Fork 18
/
backdrop.drush.inc
202 lines (165 loc) · 4.94 KB
/
backdrop.drush.inc
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<?php
/**
* @file
* Core drush commands.
*/
include_once __DIR__ . '/BackdropBoot.php';
/**
* Implements hook_bootstrap_candidates().
*
* This returns an array of classes that may be used to bootstrap Drush. Right
* now there is only a single Backdrop version, but in the future if newer
* versions required separate bootstrap classes per version, we would add them
* here.
*/
function backdrop_bootstrap_candidates() {
return array('Drush\Boot\BackdropBoot');
}
/**
* Adjust the contents of any command structure prior to dispatch.
*
* @see core_drush_command_alter()
*/
function backdrop_drush_command_alter(&$command) {
$bootstrap = drush_get_bootstrap_object();
if (!is_a($bootstrap, 'Drush\Boot\BackdropBoot')) {
return;
}
$backdrop_command = NULL;
// Commands that need replacements with Backdrop versions.
// @todo: Automate this based on the contents of the commands directory.
switch ($command['command']) {
case 'core-cron':
$backdrop_command = 'backdrop-cron';
break;
case 'updatedb':
$backdrop_command = 'backdrop-updatedb';
break;
case 'updatedb-batch-process':
$backdrop_command = 'backdrop-updatedb-batch-process';
break;
case 'updatedb-status':
$backdrop_command = 'backdrop-updatedb-status';
break;
case 'pm-download':
$backdrop_command = 'backdrop-pm-download';
break;
case 'user-login':
$backdrop_command = 'backdrop-user-login';
break;
case 'user-create':
$backdrop_command = 'backdrop-user-create';
break;
case 'core-status':
$backdrop_command = 'backdrop-core-status';
break;
case 'boilerplate':
$backdrop_command = 'backdrop-boilerplate';
break;
case 'pm-update':
$backdrop_command = 'backdrop-pm-update';
break;
case 'pm-enable':
$backdrop_command = 'backdrop-pm-enable';
break;
case 'pm-disable':
$backdrop_command = 'backdrop-pm-disable';
break;
case 'pm-uninstall':
$backdrop_command = 'backdrop-pm-uninstall';
break;
case 'backdrop-subtheme-basis':
$backdrop_command = 'backdrop-subtheme-basis';
break;
case 'user-password':
$backdrop_command = 'backdrop-user-password';
break;
case 'config-export':
$backdrop_command = 'backdrop-config-export';
break;
case 'config-import':
case 'backdrop-config-import':
$backdrop_command = 'backdrop-config-import';
break;
case 'fix-permissions':
$backdrop_command = 'fix-permissions';
break;
case 'site-install':
$backdrop_command = 'backdrop-site-install';
break;
case 'pm-list':
$backdrop_command = 'backdrop-pm-list';
break;
case 'watchdog-show':
$backdrop_command = 'watchdog-show';
break;
}
// Commands that work with Backdrop with no adjustments.
$safe_commands = array(
'cache-get',
'cache-set',
'core-exec',
'core-rsync',
'help',
'helpsingle',
'topic',
'php-eval',
'php-script',
'site-alias',
'sql-cli',
'sql-conf',
'sql-connect',
'sql-create',
'sql-drop',
'sql-dump',
'sql-query',
'sql-sanitize',
'release-notes',
'civicrm-install',
);
$compatible_commands = array(
'cache-clear',
);
// Commands native to Backdrop.
if (strpos($command['command'], 'backdrop') !== FALSE) {
return;
}
// Commands that work as-is.
if (in_array($command['command'], $safe_commands)) {
return;
}
// Commands provided by Backdrop modules relative to this site installation.
if (strpos($command['path'], '/') !== 0 && strpos($command['path'], 'modules') !== FALSE) {
return;
}
// Commands that are fine to be run through the compatibility layer.
if (in_array($command['command'], $compatible_commands)) {
require_once BACKDROP_ROOT . '/core/includes/drupal.inc';
$GLOBALS['settings']['backdrop_drupal_compatibility'] = TRUE;
$backdrop_command = $command['command'];
}
// And finally commands that are not supported (yet) use the fallback command.
$commands = drush_get_commands();
if (!isset($backdrop_command) || !array_key_exists($backdrop_command, $commands)) {
$backdrop_command = 'backdrop-unsupported';
}
// Replace the command with a Backdrop-supported one.
$arguments = $command['arguments'];
$command = $commands[$backdrop_command];
drush_set_command($command);
$command['arguments'] = $arguments;
// Add command-specific options, if applicable.
drush_command_default_options($command);
}
/**
* Implements hook_module_implements_alter().
*
* This is a hack to remove core Drush's implementation of hook_watchdog() from
* the hook registry. See system_watchdog() in Drush core.
*/
function system_module_implements_alter(&$implementations, $hook) {
// Remove system_watchdog() from being called.
if ($hook === 'watchdog') {
$implementations = array_diff_key($implementations, array('system' => NULL));
}
}