X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fdrupal%2Fconsole-core%2Fsrc%2FCommand%2FChain%2FChainCustomCommand.php;fp=vendor%2Fdrupal%2Fconsole-core%2Fsrc%2FCommand%2FChain%2FChainCustomCommand.php;h=3abd2215b94b5bbe18f9607ea9690801cba208c2;hp=0000000000000000000000000000000000000000;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad diff --git a/vendor/drupal/console-core/src/Command/Chain/ChainCustomCommand.php b/vendor/drupal/console-core/src/Command/Chain/ChainCustomCommand.php new file mode 100644 index 000000000..3abd2215b --- /dev/null +++ b/vendor/drupal/console-core/src/Command/Chain/ChainCustomCommand.php @@ -0,0 +1,107 @@ +name = $name; + $this->description = $description; + $this->file = $file; + + parent::__construct(); + } + + /** + * {@inheritdoc} + */ + protected function configure() + { + $this + ->setName($this->name) + ->setDescription($this->description) + ->addOption( + 'placeholder', + null, + InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL, + $this->trans('commands.chain.options.placeholder') + ); + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $command = $this->getApplication()->find('chain'); + + $arguments = [ + 'command' => 'chain', + '--file' => $this->file, + ]; + + if ($placeholder = $input->getOption('placeholder')) { + $arguments['--placeholder'] = $this->inlineValueAsArray($placeholder); + } + + foreach ($input->getOptions() as $option => $value) { + if ($option != 'placeholder' && $value) { + if (is_bool($value)) { + $value = true; + } + $arguments['--'.$option] = $value; + } + } + + $commandInput = new ArrayInput($arguments); + if (array_key_exists('--no-interaction', $arguments)) { + $commandInput->setInteractive(false); + } + + return $command->run($commandInput, $output); + } +}