2 namespace Drush\Command;
4 use Symfony\Component\Console\Command\Command;
5 use Symfony\Component\Console\Input\InputArgument;
6 use Symfony\Component\Console\Input\InputInterface;
7 use Symfony\Component\Console\Output\OutputInterface;
8 use Drush\Symfony\IndiscriminateInputDefinition;
10 use Drush\Runtime\RedispatchHook;
13 * Create a placeholder proxy command to represent an unknown command.
14 * We use these only when executing remote commands that do not exist
15 * locally. We will let the remote end decide whether these will be
16 * "command not found," or some other behavior, as the remote end might
17 * have additional functionality installed.
19 * Also note that, for remote commands, we create the proxy command prior
20 * to attempting to bootstrap Drupal further, so the proxy command may
21 * be used in place of some command name that is available only for
22 * Drupal sites (e.g. pm:list and friends, etc.).
24 class RemoteCommandProxy extends Command
26 /** @var RedispatchHook */
27 protected $redispatchHook;
29 public function __construct($name, RedispatchHook $redispatchHook)
31 parent::__construct($name);
32 $this->redispatchHook = $redispatchHook;
34 // Put in a special input definition to avoid option validation errors.
35 $this->setDefinition(new IndiscriminateInputDefinition());
37 // Put in a placeholder array argument to avoid validation errors.
40 InputArgument::IS_ARRAY,
41 'Proxy for command arguments'
45 protected function execute(InputInterface $input, OutputInterface $output)
47 $this->redispatchHook->redispatchIfRemote($input);
48 $name = $this->getName();
49 throw new \Exception("Command $name could not be executed remotely.");