configurationManager = $configurationManager; parent::__construct(); } /** * @{@inheritdoc} */ public function configure() { $this ->setName('site:debug') ->setDescription($this->trans('commands.site.debug.description')) ->addArgument( 'target', InputArgument::OPTIONAL, $this->trans('commands.site.debug.options.target'), null ) ->addArgument( 'property', InputArgument::OPTIONAL, $this->trans('commands.site.debug.options.property'), null ) ->setHelp($this->trans('commands.site.debug.help')); } /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); $sites = array_keys($this->configurationManager->getSites()); if (!$sites) { $io->error($this->trans('commands.site.debug.messages.invalid-sites')); return 1; } // --target argument $target = $input->getArgument('target'); if (!$target) { $tableHeader =[ $this->trans('commands.site.debug.messages.site'), ]; $io->table($tableHeader, $sites); return 0; } $targetConfig = $this->configurationManager->readTarget($target); if (!$targetConfig) { $io->error($this->trans('commands.site.debug.messages.invalid-site')); return 1; } // --property argument, allows the user to fetch specific properties of the selected site $property = $input->getArgument('property'); if ($property) { $property_keys = explode('.', $property); $val = $targetConfig; foreach ($property_keys as $property_key) { $val = &$val[$property_key]; } $io->writeln($val); return 0; } $io->info($target); $dumper = new Dumper(); $io->writeln($dumper->dump($targetConfig, 2)); return 0; } }