4 use Drush\Log\LogLevel;
9 * Commands that only preflight, but do not bootstrap, should use
10 * a bootstrap level of DRUSH_BOOTSTRAP_NONE.
12 define('DRUSH_BOOTSTRAP_NONE', 0);
15 * Use drush_bootstrap_max instead of drush_bootstrap_to_phase
17 * This constant is only usable as the value of the 'bootstrap'
18 * item of a command object, or as the parameter to
19 * drush_bootstrap_to_phase. It is not a real bootstrap state.
21 define('DRUSH_BOOTSTRAP_MAX', -2);
26 * No longer used, but 0 remains reserved. Drush always runs preflight.
27 * Commands may alternatively use DRUSH_BOOTSTRAP_NONE.
29 define('DRUSH_BOOTSTRAP_DRUSH', 0);
32 * Set up and test for a valid drupal root, either through the -r/--root options,
33 * or evaluated based on the current working directory.
35 * Any code that interacts with an entire Drupal installation, and not a specific
36 * site on the Drupal installation should use this bootstrap phase.
38 define('DRUSH_BOOTSTRAP_DRUPAL_ROOT', 1);
41 * Set up a Drupal site directory and the correct environment variables to
42 * allow Drupal to find the configuration file.
44 * If no site is specified with the -l / --uri options, Drush will assume the
45 * site is 'default', which mimics Drupal's behaviour.
47 * If you want to avoid this behaviour, it is recommended that you use the
48 * DRUSH_BOOTSTRAP_DRUPAL_ROOT bootstrap phase instead.
50 * Any code that needs to modify or interact with a specific Drupal site's
51 * settings.php file should bootstrap to this phase.
53 define('DRUSH_BOOTSTRAP_DRUPAL_SITE', 2);
56 * Load the settings from the Drupal sites directory.
58 * This phase is analagous to the DRUPAL_BOOTSTRAP_CONFIGURATION bootstrap phase in Drupal
59 * itself, and this is also the first step where Drupal specific code is included.
61 * This phase is commonly used for code that interacts with the Drupal install API,
62 * as both install.php and update.php start at this phase.
64 define('DRUSH_BOOTSTRAP_DRUPAL_CONFIGURATION', 3);
67 * Connect to the Drupal database using the database credentials loaded
68 * during the previous bootstrap phase.
70 * This phase is analogous to the DRUPAL_BOOTSTRAP_DATABASE bootstrap phase in
73 * Any code that needs to interact with the Drupal database API needs to
74 * be bootstrapped to at least this phase.
76 define('DRUSH_BOOTSTRAP_DRUPAL_DATABASE', 4);
79 * Fully initialize Drupal.
81 * This is analogous to the DRUPAL_BOOTSTRAP_FULL bootstrap phase in
84 * Any code that interacts with the general Drupal API should be
85 * bootstrapped to this phase.
87 define('DRUSH_BOOTSTRAP_DRUPAL_FULL', 5);
92 * Helper function to store any context settings that are being validated.
94 function drush_bootstrap_value($context, $value = null) {
95 $values =& drush_get_context('DRUSH_BOOTSTRAP_VALUES', []);
98 $values[$context] = $value;
101 if (array_key_exists($context, $values)) {
102 return $values[$context];
109 * Helper function to collect any errors that occur during the bootstrap process.
110 * Always returns FALSE, for convenience.
112 function drush_bootstrap_error($code, $message = null) {
113 $errors = drush_get_context('DRUSH_BOOTSTRAP_ERRORS');
114 $errors[$code] = $message;
115 drush_set_context('DRUSH_BOOTSTRAP_ERRORS', $errors);