5 * Contains \Drupal\Console\Command\Config\DebugCommand.
8 namespace Drupal\Console\Command\Config;
10 use Symfony\Component\Console\Input\InputArgument;
11 use Symfony\Component\Console\Input\InputInterface;
12 use Symfony\Component\Console\Output\OutputInterface;
13 use Drupal\Component\Serialization\Yaml;
14 use Drupal\Core\Config\CachedStorage;
15 use Drupal\Core\Config\ConfigFactory;
16 use Symfony\Component\Console\Command\Command;
17 use Drupal\Console\Core\Command\Shared\CommandTrait;
18 use Drupal\Console\Core\Style\DrupalStyle;
20 class DebugCommand extends Command
27 protected $configFactory;
32 protected $configStorage;
35 * DebugCommand constructor.
37 * @param ConfigFactory $configFactory
38 * @param CachedStorage $configStorage
40 public function __construct(
41 ConfigFactory $configFactory,
42 CachedStorage $configStorage
44 $this->configFactory = $configFactory;
45 $this->configStorage = $configStorage;
46 parent::__construct();
52 protected function configure()
55 ->setName('config:debug')
56 ->setDescription($this->trans('commands.config.debug.description'))
59 InputArgument::OPTIONAL,
60 $this->trans('commands.config.debug.arguments.name')
67 protected function execute(InputInterface $input, OutputInterface $output)
69 $io = new DrupalStyle($input, $output);
71 $configName = $input->getArgument('name');
73 $this->getAllConfigurations($io);
75 $this->getConfigurationByName($io, $configName);
80 * @param $io DrupalStyle
82 private function getAllConfigurations(DrupalStyle $io)
84 $names = $this->configFactory->listAll();
86 $this->trans('commands.config.debug.arguments.name'),
89 foreach ($names as $name) {
95 $io->table($tableHeader, $tableRows, 'compact');
99 * @param $io DrupalStyle
100 * @param $config_name String
102 private function getConfigurationByName(DrupalStyle $io, $config_name)
104 if ($this->configStorage->exists($config_name)) {
109 $configuration = $this->configStorage->read($config_name);
110 $configurationEncoded = Yaml::encode($configuration);
113 $configurationEncoded,
116 $io->table($tableHeader, $tableRows, 'compact');
119 sprintf($this->trans('commands.config.debug.errors.not-exists'), $config_name)