db backup prior to drupal security update
[yaffs-website] / vendor / drupal / console-core / src / Command / Settings / DebugCommand.php
1 <?php
2
3 /**
4  * @file
5  * Contains \Drupal\Console\Core\Command\Settings\DebugCommand.
6  */
7
8 namespace Drupal\Console\Core\Command\Settings;
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\Command\Shared\CommandTrait;
14 use Drupal\Console\Core\Utils\ConfigurationManager;
15 use Drupal\Console\Core\Utils\NestedArray;
16 use Drupal\Console\Core\Style\DrupalStyle;
17
18 /**
19  * Class DebugCommand
20  *
21  * @package Drupal\Console\Core\Command\Settings
22  */
23 class DebugCommand extends Command
24 {
25     use CommandTrait;
26
27     /**
28      * @var ConfigurationManager
29      */
30     protected $configurationManager;
31
32     /**
33      * @var NestedArray
34      */
35     protected $nestedArray;
36
37     /**
38      * CheckCommand constructor.
39      *
40      * @param ConfigurationManager $configurationManager
41      * @param NestedArray          $nestedArray
42      */
43     public function __construct(
44         ConfigurationManager $configurationManager,
45         NestedArray $nestedArray
46     ) {
47         $this->configurationManager = $configurationManager;
48         $this->nestedArray = $nestedArray;
49         parent::__construct();
50     }
51
52     /**
53      * {@inheritdoc}
54      */
55     protected function configure()
56     {
57         $this
58             ->setName('settings:debug')
59             ->setDescription($this->trans('commands.settings.debug.description'));
60     }
61
62     /**
63      * {@inheritdoc}
64      */
65     protected function execute(InputInterface $input, OutputInterface $output)
66     {
67         $io = new DrupalStyle($input, $output);
68
69         $configuration = $this->configurationManager->getConfiguration();
70         $configApplication = $configuration->get('application');
71
72         unset($configApplication['autowire']);
73         unset($configApplication['languages']);
74         unset($configApplication['aliases']);
75         unset($configApplication['composer']);
76         unset($configApplication['default']['commands']);
77
78         $configApplicationFlatten = [];
79         $keyFlatten = '';
80
81         $this->nestedArray->yamlFlattenArray(
82             $configApplication,
83             $configApplicationFlatten,
84             $keyFlatten
85         );
86
87         $tableHeader = [
88             $this->trans('commands.settings.debug.messages.config-key'),
89             $this->trans('commands.settings.debug.messages.config-value'),
90         ];
91
92         $tableRows = [];
93         foreach ($configApplicationFlatten as $ymlKey => $ymlValue) {
94             $tableRows[] = [
95                 $ymlKey,
96                 $ymlValue
97             ];
98         }
99
100         $io->newLine();
101         $io->info(
102             sprintf(
103                 '%s :',
104                 $this->trans('commands.settings.debug.messages.config-file')
105             ),
106             false
107         );
108
109         $io->comment(
110             sprintf(
111                 '%s/.console/config.yml',
112                 $this->configurationManager->getHomeDirectory()
113             ),
114             true
115         );
116
117         $io->newLine();
118
119         $io->table($tableHeader, $tableRows, 'compact');
120
121         return 0;
122     }
123 }