db backup prior to drupal security update
[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  *
20  * @package Drupal\Console\Core\Command\Chain
21  */
22 class ChainDebugCommand extends Command
23 {
24     use CommandTrait;
25
26     /**
27      * @var ChainDiscovery
28      */
29     protected $chainDiscovery;
30
31     /**
32      * ChainDebugCommand constructor.
33      *
34      * @param ChainDiscovery $chainDiscovery
35      */
36     public function __construct(
37         ChainDiscovery $chainDiscovery
38     ) {
39         $this->chainDiscovery = $chainDiscovery;
40
41         parent::__construct();
42     }
43
44     /**
45      * {@inheritdoc}
46      */
47     protected function configure()
48     {
49         $this
50             ->setName('chain:debug')
51             ->setDescription($this->trans('commands.chain.debug.description'));
52     }
53
54     /**
55      * {@inheritdoc}
56      */
57     protected function execute(InputInterface $input, OutputInterface $output)
58     {
59         $io = new DrupalStyle($input, $output);
60         $files = $this->chainDiscovery->getChainFiles();
61
62         foreach ($files as $directory => $chainFiles) {
63             $io->info($this->trans('commands.chain.debug.messages.directory'), false);
64             $io->comment($directory);
65
66             $tableHeader = [
67               $this->trans('commands.chain.debug.messages.file')
68             ];
69
70             $tableRows = [];
71             foreach ($chainFiles as $file) {
72                 $tableRows[] = $file;
73             }
74
75             $io->table($tableHeader, $tableRows);
76         }
77
78         return 0;
79     }
80 }