More updates to stop using dev or alpha or beta versions.
[yaffs-website] / vendor / drush / drush / includes / bootstrap.inc
1 <?php
2
3 use Drush\Drush;
4 use Drush\Log\LogLevel;
5
6 /**
7  * No bootstrap.
8  *
9  * Commands that only preflight, but do not bootstrap, should use
10  * a bootstrap level of DRUSH_BOOTSTRAP_NONE.
11  */
12 define('DRUSH_BOOTSTRAP_NONE', 0);
13
14 /**
15  * Use drush_bootstrap_max instead of drush_bootstrap_to_phase
16  *
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.
20  */
21 define('DRUSH_BOOTSTRAP_MAX', -2);
22
23 /**
24  * @deprecated
25  *
26  * No longer used, but 0 remains reserved. Drush always runs preflight.
27  * Commands may alternatively use DRUSH_BOOTSTRAP_NONE.
28  */
29 define('DRUSH_BOOTSTRAP_DRUSH', 0);
30
31 /**
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.
34  *
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.
37  */
38 define('DRUSH_BOOTSTRAP_DRUPAL_ROOT',  1);
39
40 /**
41  * Set up a Drupal site directory and the correct environment variables to
42  * allow Drupal to find the configuration file.
43  *
44  * If no site is specified with the -l / --uri options, Drush will assume the
45  * site is 'default', which mimics Drupal's behaviour.
46  *
47  * If you want to avoid this behaviour, it is recommended that you use the
48  * DRUSH_BOOTSTRAP_DRUPAL_ROOT bootstrap phase instead.
49  *
50  * Any code that needs to modify or interact with a specific Drupal site's
51  * settings.php file should bootstrap to this phase.
52  */
53 define('DRUSH_BOOTSTRAP_DRUPAL_SITE', 2);
54
55 /**
56  * Load the settings from the Drupal sites directory.
57  *
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.
60  *
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.
63  */
64 define('DRUSH_BOOTSTRAP_DRUPAL_CONFIGURATION', 3);
65
66 /**
67  * Connect to the Drupal database using the database credentials loaded
68  * during the previous bootstrap phase.
69  *
70  * This phase is analogous to the DRUPAL_BOOTSTRAP_DATABASE bootstrap phase in
71  * Drupal.
72  *
73  * Any code that needs to interact with the Drupal database API needs to
74  * be bootstrapped to at least this phase.
75  */
76 define('DRUSH_BOOTSTRAP_DRUPAL_DATABASE', 4);
77
78 /**
79  * Fully initialize Drupal.
80  *
81  * This is analogous to the DRUPAL_BOOTSTRAP_FULL bootstrap phase in
82  * Drupal.
83  *
84  * Any code that interacts with the general Drupal API should be
85  * bootstrapped to this phase.
86  */
87 define('DRUSH_BOOTSTRAP_DRUPAL_FULL', 5);
88
89
90
91 /**
92  * Helper function to store any context settings that are being validated.
93  */
94 function drush_bootstrap_value($context, $value = null) {
95   $values =& drush_get_context('DRUSH_BOOTSTRAP_VALUES', []);
96
97   if (isset($value)) {
98     $values[$context] = $value;
99   }
100
101   if (array_key_exists($context, $values)) {
102     return $values[$context];
103   }
104
105   return null;
106 }
107
108 /**
109  * Helper function to collect any errors that occur during the bootstrap process.
110  * Always returns FALSE, for convenience.
111  */
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);
116   return FALSE;
117 }