Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / drush / drush / src / Boot / BaseBoot.php
1 <?php
2
3 namespace Drush\Boot;
4
5 use Drush\Drush;
6 use Drush\Log\LogLevel;
7 use Psr\Log\LoggerInterface;
8 use Psr\Log\LoggerAwareInterface;
9 use Psr\Log\LoggerAwareTrait;
10 use League\Container\ContainerAwareInterface;
11 use League\Container\ContainerAwareTrait;
12
13 use Symfony\Component\Console\Input\ArgvInput;
14
15 abstract class BaseBoot implements Boot, LoggerAwareInterface, ContainerAwareInterface
16 {
17     use LoggerAwareTrait;
18     use ContainerAwareTrait;
19
20     protected $uri;
21
22     public function __construct()
23     {
24         register_shutdown_function([$this, 'terminate']);
25     }
26
27     public function findUri($root, $uri)
28     {
29         return 'default';
30     }
31
32     public function setUri($uri)
33     {
34         $this->uri = $uri;
35     }
36
37     public function validRoot($path)
38     {
39     }
40
41     public function getVersion($root)
42     {
43     }
44
45     public function commandDefaults()
46     {
47     }
48
49     public function reportCommandError($command)
50     {
51         // Set errors related to this command.
52         $args = implode(' ', drush_get_arguments());
53         if (isset($command) && is_array($command)) {
54             foreach ($command['bootstrap_errors'] as $key => $error) {
55                 drush_set_error($key, $error);
56             }
57             drush_set_error('DRUSH_COMMAND_NOT_EXECUTABLE', dt("The Drush command '!args' could not be executed.", ['!args' => $args]));
58         } elseif (!empty($args)) {
59             drush_set_error('DRUSH_COMMAND_NOT_FOUND', dt("The Drush command '!args' could not be found. Use 'drush core-status' to verify that Drupal is found and bootstrapped successfully. Look for 'Drupal bootstrap : Successful' in its output.", ['!args' => $args]));
60         }
61         // Set errors that occurred in the bootstrap phases.
62         $errors = drush_get_context('DRUSH_BOOTSTRAP_ERRORS', []);
63         foreach ($errors as $code => $message) {
64             drush_set_error($code, $message);
65         }
66     }
67
68     public function bootstrapPhases()
69     {
70         return [
71             DRUSH_BOOTSTRAP_DRUSH => 'bootstrapDrush',
72         ];
73     }
74
75     public function bootstrapPhaseMap()
76     {
77         return [
78             'none' => DRUSH_BOOTSTRAP_DRUSH,
79             'drush' => DRUSH_BOOTSTRAP_DRUSH,
80             'max' => DRUSH_BOOTSTRAP_MAX,
81             'root' => DRUSH_BOOTSTRAP_DRUPAL_ROOT,
82             'site' => DRUSH_BOOTSTRAP_DRUPAL_SITE,
83             'configuration' => DRUSH_BOOTSTRAP_DRUPAL_CONFIGURATION,
84             'database' => DRUSH_BOOTSTRAP_DRUPAL_DATABASE,
85             'full' => DRUSH_BOOTSTRAP_DRUPAL_FULL
86         ];
87     }
88
89     public function lookUpPhaseIndex($phase)
90     {
91         $phaseMap = $this->bootstrapPhaseMap();
92         if (isset($phaseMap[$phase])) {
93             return $phaseMap[$phase];
94         }
95
96         if ((substr($phase, 0, 16) != 'DRUSH_BOOTSTRAP_') || (!defined($phase))) {
97             return;
98         }
99         return constant($phase);
100     }
101
102     public function bootstrapDrush()
103     {
104     }
105
106     protected function hasRegisteredSymfonyCommand($application, $name)
107     {
108         try {
109             $application->get($name);
110             return true;
111         } catch (\InvalidArgumentException $e) {
112             return false;
113         }
114     }
115
116     protected function inflect($object)
117     {
118         // See \Drush\Runtime\DependencyInjection::addDrushServices and
119         // \Robo\Robo\addInflectors
120         $container = $this->getContainer();
121         if ($object instanceof \Robo\Contract\ConfigAwareInterface) {
122             $object->setConfig($container->get('config'));
123         }
124         if ($object instanceof \Psr\Log\LoggerAwareInterface) {
125             $object->setLogger($container->get('logger'));
126         }
127         if ($object instanceof \League\Container\ContainerAwareInterface) {
128             $object->setContainer($container->get('container'));
129         }
130         if ($object instanceof \Symfony\Component\Console\Input\InputAwareInterface) {
131             $object->setInput($container->get('input'));
132         }
133         if ($object instanceof \Robo\Contract\OutputAwareInterface) {
134             $object->setOutput($container->get('output'));
135         }
136         if ($object instanceof \Robo\Contract\ProgressIndicatorAwareInterface) {
137             $object->setProgressIndicator($container->get('progressIndicator'));
138         }
139         if ($object instanceof \Consolidation\AnnotatedCommand\Events\CustomEventAwareInterface) {
140             $object->setHookManager($container->get('hookManager'));
141         }
142         if ($object instanceof \Robo\Contract\VerbosityThresholdInterface) {
143             $object->setOutputAdapter($container->get('outputAdapter'));
144         }
145         if ($object instanceof \Consolidation\SiteAlias\SiteAliasManagerAwareInterface) {
146             $object->setOutputAdapter($container->get('site.alias.manager'));
147         }
148     }
149
150     /**
151      * {@inheritdoc}
152      */
153     public function terminate()
154     {
155     }
156 }