Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / vendor / drush / drush / src / Command / GlobalOptionsEventListener.php
1 <?php
2 namespace Drush\Command;
3
4 use Symfony\Component\Console\ConsoleEvents;
5 use Symfony\Component\Console\Event\ConsoleCommandEvent;
6 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
7
8 use Drush\Preflight\LegacyPreflight;
9
10 class GlobalOptionsEventListener implements EventSubscriberInterface
11 {
12     /**
13      * @{@inheritdoc}
14      */
15     public static function getSubscribedEvents()
16     {
17         // Register our 'setGlobalOptions' command to run prior to
18         // command dispatch.
19         return [ConsoleEvents::COMMAND => 'setGlobalOptions'];
20     }
21
22     /**
23      * Before a Console command runs, examine the global
24      * commandline options from the event Input, and set
25      * configuration values as appropriate.
26      *
27      * @param ConsoleCommandEvent $event
28      */
29     public function setGlobalOptions(ConsoleCommandEvent $event)
30     {
31         /* @var Input $input */
32         $input = $event->getInput();
33         $output = $event->getOutput();
34
35         // TODO: We need a good strategy for managing global options.
36         // $simulate = $input->getOption('simulate');
37
38         // Set up legacy contexts (deprecated)
39         LegacyPreflight::setGlobalOptionContexts($input, $output);
40     }
41 }