Added the Search API Synonym module to deal specifically with licence and license...
[yaffs-website] / vendor / drupal / console-core / src / Command / Chain / ChainCustomCommand.php
1 <?php
2
3 /**
4  * @file
5  * Contains Drupal\Console\Core\Command\ChainCustomCommand.
6  */
7
8 namespace Drupal\Console\Core\Command\Chain;
9
10 use Symfony\Component\Console\Input\ArrayInput;
11 use Symfony\Component\Console\Input\InputInterface;
12 use Symfony\Component\Console\Input\InputOption;
13 use Symfony\Component\Console\Output\OutputInterface;
14 use Drupal\Console\Core\Command\Shared\InputTrait;
15
16 /**
17  * Class ChainCustomCommand
18  *
19  * @package Drupal\Console\Core\Command\ChainCustomCommand
20  */
21 class ChainCustomCommand extends BaseCommand
22 {
23     use InputTrait;
24
25     /**
26      * @var string
27      */
28     protected $name;
29
30     /**
31      * @var string
32      */
33     protected $description;
34
35     /**
36      * @var string
37      */
38     protected $file;
39
40     /**
41      * ChainCustomCommand constructor.
42      *
43      * @param $name
44      * @param $description
45      * @param $file
46      * @param $chainDiscovery
47      */
48     public function __construct(
49         $name,
50         $description,
51         $file,
52         $chainDiscovery
53     ) {
54         $this->name = $name;
55         $this->description = $description;
56         $this->file = $file;
57
58         parent::__construct($chainDiscovery);
59         $this->ignoreValidationErrors();
60
61         $this->addOption(
62             'file',
63             null,
64             InputOption::VALUE_OPTIONAL,
65             null,
66             $file
67         );
68     }
69
70     /**
71      * {@inheritdoc}
72      */
73     protected function configure()
74     {
75         $this
76             ->setName($this->name)
77             ->setDescription($this->description);
78     }
79
80     /**
81      * {@inheritdoc}
82      */
83     protected function execute(InputInterface $input, OutputInterface $output)
84     {
85         $command = $this->getApplication()->find('chain');
86
87         $arguments = [
88             'command' => 'chain',
89             '--file'  => $this->file,
90         ];
91
92         foreach ($input->getOptions() as $option => $value) {
93             if ($value) {
94                 $arguments['--' . $option] = $value;
95             }
96         }
97
98         $commandInput = new ArrayInput($arguments);
99         $commandInput->setInteractive(true);
100
101         return $command->run($commandInput, $output);
102     }
103 }