d5936707f0267055df5ce8ad0e36334ca9fb0a6f
[yaffs-website] / vendor / drupal / console-core / src / Command / Chain / ChainDebugCommand.php
1 <?php
2
3 /**
4  * @file
5  * Contains \Drupal\Console\Core\Command\Chain\ChainDebugCommand.
6  */
7
8 namespace Drupal\Console\Core\Command\Chain;
9
10 use Symfony\Component\Console\Input\InputInterface;
11 use Symfony\Component\Console\Output\OutputInterface;
12 use Symfony\Component\Console\Command\Command;
13 use Drupal\Console\Core\Utils\ChainDiscovery;
14 use Drupal\Console\Core\Style\DrupalStyle;
15 use Drupal\Console\Core\Command\Shared\CommandTrait;
16
17 /**
18  * Class ChainDebugCommand
19  * @package Drupal\Console\Core\Command\Chain
20  */
21 class ChainDebugCommand extends Command
22 {
23     use CommandTrait;
24
25     /**
26      * @var ChainDiscovery
27      */
28     protected $chainDiscovery;
29
30     /**
31      * ChainDebugCommand constructor.
32      *
33      * @param ChainDiscovery $chainDiscovery
34      */
35     public function __construct(
36         ChainDiscovery $chainDiscovery
37     ) {
38         $this->chainDiscovery = $chainDiscovery;
39
40         parent::__construct();
41     }
42
43     /**
44      * {@inheritdoc}
45      */
46     protected function configure()
47     {
48         $this
49             ->setName('chain:debug')
50             ->setDescription($this->trans('commands.chain.debug.description'));
51     }
52
53     /**
54      * {@inheritdoc}
55      */
56     protected function execute(InputInterface $input, OutputInterface $output)
57     {
58         $io = new DrupalStyle($input, $output);
59         $files = $this->chainDiscovery->getChainFiles();
60
61         foreach ($files as $directory => $chainFiles) {
62             $io->info($this->trans('commands.chain.debug.messages.directory'), false);
63             $io->comment($directory);
64
65             $tableHeader = [
66               $this->trans('commands.chain.debug.messages.file')
67             ];
68
69             $tableRows = [];
70             foreach ($chainFiles as $file) {
71                 $tableRows[] = $file;
72             }
73
74             $io->table($tableHeader, $tableRows);
75         }
76
77         return 0;
78     }
79 }