2 namespace Drush\Preflight;
5 use Drush\Config\Environment;
6 use Symfony\Component\Console\Input\InputInterface;
7 use Symfony\Component\Console\Output\OutputInterface;
8 use Webmozart\PathUtil\Path;
11 * Prepare to bootstrap Drupal
13 * - Determine the site to use
14 * - Set up the DI container
15 * - Start the bootstrap process
20 * Define legacy constants.
22 public static function defineConstants(Environment $environment, $applicationPath)
24 $applicationPath = Path::makeAbsolute($applicationPath, $environment->cwd());
26 define('DRUSH_REQUEST_TIME', microtime(true));
29 * @deprecated. Use $config->get('drush.base-dir') instead.
31 define('DRUSH_BASE_PATH', $environment->drushBasePath());
34 * @deprecated. Use Drush::getVersion().
36 define('DRUSH_VERSION', Drush::getVersion());
39 * @deprecated. Use Drush::getMajorVersion().
41 define('DRUSH_MAJOR_VERSION', Drush::getMajorVersion());
44 * @deprecated. Use Drush::getMinorVersion().
46 define('DRUSH_MINOR_VERSION', Drush::getMinorVersion());
51 define('DRUSH_COMMAND', $applicationPath);
54 * @deprecated. Use $config->cwd() instead.
56 drush_set_context('DRUSH_OLDCWD', $environment->cwd());
59 * @deprecated. Do not use
61 drush_set_context('argc', $GLOBALS['argc']);
62 drush_set_context('argv', $GLOBALS['argv']);
65 * @deprecated. Use $config->get('drush.vendor-dir') instead.
67 drush_set_context('DRUSH_VENDOR_PATH', $environment->vendorPath());
70 public static function setContexts(Environment $environment)
73 * Obsolete. Presumed to be unnecessary; available in Environment if needed
74 * (just add a getter method).
76 // drush_set_context('ETC_PREFIX', $environment->...);
77 // drush_set_context('SHARE_PREFIX', $environment->...);
80 * @deprecated. Use $config->get('drush.docs-dir') instead.
82 drush_set_context('DRUSH_BASE_PATH', $environment->docsPath());
85 * @deprecated. Use $config->get('drush.system-dir') instead.
87 drush_set_context('DRUSH_SITE_WIDE_CONFIGURATION', $environment->systemConfigPath());
90 * @deprecated. Use $config->get('drush.system-command-dir') instead.
92 drush_set_context('DRUSH_SITE_WIDE_COMMANDFILES', $environment->systemCommandFilePath());
95 * @deprecated. Use $config->get('drush.user-dir') instead.
97 drush_set_context('DRUSH_PER_USER_CONFIGURATION', $environment->userConfigPath());
100 public static function setGlobalOptionContexts(InputInterface $input, OutputInterface $output)
102 $verbose = $output->isVerbose();
103 $debug = $output->isDebug();
104 $quiet = $input->getOption('quiet', false);
105 $pipe = $input->getOption('pipe', false);
106 $simulate = Drush::simulate();
108 drush_set_context('DRUSH_VERBOSE', $verbose || $debug);
109 drush_set_context('DRUSH_DEBUG', $debug);
110 drush_set_context('DRUSH_DEBUG_NOTIFY', $verbose && $debug);
111 drush_set_context('DRUSH_SIMULATE', $simulate);
113 // Pipe implies quiet.
114 drush_set_context('DRUSH_QUIET', $quiet || $pipe);
118 * Include old code. It is an aspirational goal to remove or refactor
119 * all of this into more modular, class-based code.
121 public static function includeCode($drushBasePath)
123 // We still need preflight for drush_shutdown()
124 require_once $drushBasePath . '/includes/preflight.inc';
125 require_once $drushBasePath . '/includes/bootstrap.inc';
126 require_once $drushBasePath . '/includes/environment.inc';
127 require_once $drushBasePath . '/includes/command.inc';
128 require_once $drushBasePath . '/includes/drush.inc';
129 require_once $drushBasePath . '/includes/backend.inc';
130 require_once $drushBasePath . '/includes/batch.inc';
131 require_once $drushBasePath . '/includes/context.inc';
132 require_once $drushBasePath . '/includes/sitealias.inc';
133 require_once $drushBasePath . '/includes/exec.inc';
134 require_once $drushBasePath . '/includes/drupal.inc';
135 require_once $drushBasePath . '/includes/output.inc';
136 require_once $drushBasePath . '/includes/cache.inc';
137 require_once $drushBasePath . '/includes/filesystem.inc';