5 * Contains \Drupal\Console\Core\Command\Site\DebugCommand.
8 namespace Drupal\Console\Core\Command\Site;
10 use Symfony\Component\Console\Input\InputArgument;
11 use Symfony\Component\Console\Input\InputInterface;
12 use Symfony\Component\Console\Output\OutputInterface;
13 use Symfony\Component\Yaml\Dumper;
14 use Symfony\Component\Console\Command\Command;
15 use Drupal\Console\Core\Command\Shared\CommandTrait;
16 use Drupal\Console\Core\Utils\ConfigurationManager;
17 use Drupal\Console\Core\Style\DrupalStyle;
20 * Class SiteDebugCommand
22 * @package Drupal\Console\Core\Command\Site
24 class DebugCommand extends Command
29 * @var ConfigurationManager
31 protected $configurationManager;
34 * DebugCommand constructor.
36 * @param ConfigurationManager $configurationManager
38 public function __construct(
39 ConfigurationManager $configurationManager
41 $this->configurationManager = $configurationManager;
42 parent::__construct();
48 public function configure()
51 ->setName('site:debug')
52 ->setDescription($this->trans('commands.site.debug.description'))
55 InputArgument::OPTIONAL,
56 $this->trans('commands.site.debug.options.target'),
61 InputArgument::OPTIONAL,
62 $this->trans('commands.site.debug.options.property'),
65 ->setHelp($this->trans('commands.site.debug.help'));
71 protected function execute(InputInterface $input, OutputInterface $output)
73 $io = new DrupalStyle($input, $output);
75 $sites = array_keys($this->configurationManager->getSites());
78 $io->error($this->trans('commands.site.debug.messages.invalid-sites'));
85 $target = $input->getArgument('target');
88 $this->trans('commands.site.debug.messages.site'),
91 $io->table($tableHeader, $sites);
96 $targetConfig = $this->configurationManager->readTarget($target);
98 $io->error($this->trans('commands.site.debug.messages.invalid-site'));
103 // --property argument, allows the user to fetch specific properties of the selected site
104 $property = $input->getArgument('property');
106 $property_keys = explode('.', $property);
108 $val = $targetConfig;
109 foreach ($property_keys as $property_key) {
110 $val = &$val[$property_key];
118 $dumper = new Dumper();
119 $io->writeln($dumper->dump($targetConfig, 2));