forked from drush-ops/drush
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GlobalOptionsEventListener.php
38 lines (33 loc) · 1.09 KB
/
GlobalOptionsEventListener.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
namespace Drush\Command;
use Symfony\Component\Console\ConsoleEvents;
use Symfony\Component\Console\Event\ConsoleCommandEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Drush\Preflight\LegacyPreflight;
class GlobalOptionsEventListener implements EventSubscriberInterface
{
/**
* @{@inheritdoc}
*/
public static function getSubscribedEvents(): array
{
// Register our 'setGlobalOptions' command to run prior to
// command dispatch.
return [ConsoleEvents::COMMAND => 'setGlobalOptions'];
}
/**
* Before a Console command runs, examine the global
* commandline options from the event Input, and set
* configuration values as appropriate.
*
* @param ConsoleCommandEvent $event
*/
public function setGlobalOptions(ConsoleCommandEvent $event): void
{
/* @var Input $input */
$input = $event->getInput();
$output = $event->getOutput();
// TODO: We need a good strategy for managing global options.
// $simulate = $input->getOption('simulate');
}
}