b72599c4309ae5598ecca0d8cacc23b95169cbb6
[yaffs-website] / vendor / drush / drush / src / Preflight / LegacyPreflight.php
1 <?php
2 namespace Drush\Preflight;
3
4 use Drush\Drush;
5 use Drush\Config\Environment;
6 use Symfony\Component\Console\Input\InputInterface;
7 use Symfony\Component\Console\Output\OutputInterface;
8 use Webmozart\PathUtil\Path;
9
10 /**
11  * Prepare to bootstrap Drupal
12  *
13  * - Determine the site to use
14  * - Set up the DI container
15  * - Start the bootstrap process
16  */
17 class LegacyPreflight
18 {
19     /**
20      * Define legacy constants.
21      */
22     public static function defineConstants(Environment $environment, $applicationPath)
23     {
24         $applicationPath = Path::makeAbsolute($applicationPath, $environment->cwd());
25
26         define('DRUSH_REQUEST_TIME', microtime(true));
27
28         /*
29          * @deprecated. Use $config->get('drush.base-dir') instead.
30          */
31         define('DRUSH_BASE_PATH', $environment->drushBasePath());
32
33         /*
34          * @deprecated. Use Drush::getVersion().
35          */
36         define('DRUSH_VERSION', Drush::getVersion());
37
38         /*
39          * @deprecated. Use Drush::getMajorVersion().
40          */
41         define('DRUSH_MAJOR_VERSION', Drush::getMajorVersion());
42
43         /*
44          * @deprecated. Use Drush::getMinorVersion().
45          */
46         define('DRUSH_MINOR_VERSION', Drush::getMinorVersion());
47
48         /*
49          * @deprecated.
50          */
51         define('DRUSH_COMMAND', $applicationPath);
52
53         /*
54          * @deprecated. Use $config->cwd() instead.
55          */
56         drush_set_context('DRUSH_OLDCWD', $environment->cwd());
57
58         /*
59          * @deprecated. Do not use
60          */
61         drush_set_context('argc', $GLOBALS['argc']);
62         drush_set_context('argv', $GLOBALS['argv']);
63
64         /*
65          * @deprecated. Use $config->get('drush.vendor-dir') instead.
66          */
67         drush_set_context('DRUSH_VENDOR_PATH', $environment->vendorPath());
68     }
69
70     public static function setContexts(Environment $environment)
71     {
72         /*
73          * Obsolete. Presumed to be unnecessary; available in Environment if needed
74          * (just add a getter method).
75          */
76         // drush_set_context('ETC_PREFIX', $environment->...);
77         // drush_set_context('SHARE_PREFIX', $environment->...);
78
79         /*
80          * @deprecated. Use $config->get('drush.docs-dir') instead.
81          */
82         drush_set_context('DRUSH_BASE_PATH', $environment->docsPath());
83
84         /*
85          * @deprecated. Use $config->get('drush.system-dir') instead.
86          */
87         drush_set_context('DRUSH_SITE_WIDE_CONFIGURATION', $environment->systemConfigPath());
88
89         /*
90          * @deprecated. Use $config->get('drush.system-command-dir') instead.
91          */
92         drush_set_context('DRUSH_SITE_WIDE_COMMANDFILES', $environment->systemCommandFilePath());
93
94         /*
95          * @deprecated. Use $config->get('drush.user-dir') instead.
96          */
97         drush_set_context('DRUSH_PER_USER_CONFIGURATION', $environment->userConfigPath());
98     }
99
100     public static function setGlobalOptionContexts(InputInterface $input, OutputInterface $output)
101     {
102         $verbose = $output->isVerbose();
103         $debug = $output->isDebug();
104         $quiet = $input->getOption('quiet', false);
105         $pipe = $input->getOption('pipe', false);
106         $simulate = Drush::simulate();
107
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);
112
113         // Pipe implies quiet.
114         drush_set_context('DRUSH_QUIET', $quiet || $pipe);
115     }
116
117     /**
118      * Include old code. It is an aspirational goal to remove or refactor
119      * all of this into more modular, class-based code.
120      */
121     public static function includeCode($drushBasePath)
122     {
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';
138     }
139 }