2 namespace Drush\Command;
4 use Symfony\Component\Console\ConsoleEvents;
5 use Symfony\Component\Console\Event\ConsoleCommandEvent;
6 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
8 use Drush\Preflight\LegacyPreflight;
10 class GlobalOptionsEventListener implements EventSubscriberInterface
15 public static function getSubscribedEvents()
17 // Register our 'setGlobalOptions' command to run prior to
19 return [ConsoleEvents::COMMAND => 'setGlobalOptions'];
23 * Before a Console command runs, examine the global
24 * commandline options from the event Input, and set
25 * configuration values as appropriate.
27 * @param ConsoleCommandEvent $event
29 public function setGlobalOptions(ConsoleCommandEvent $event)
31 /* @var Input $input */
32 $input = $event->getInput();
33 $output = $event->getOutput();
35 // TODO: We need a good strategy for managing global options.
36 // $simulate = $input->getOption('simulate');
38 // Set up legacy contexts (deprecated)
39 LegacyPreflight::setGlobalOptionContexts($input, $output);