X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fdrupal%2Fconsole-core%2Fsrc%2FCommand%2FDebug%2FSiteCommand.php;fp=vendor%2Fdrupal%2Fconsole-core%2Fsrc%2FCommand%2FDebug%2FSiteCommand.php;h=b496b2aa3af127d473989c18b34c6b22a5a08e2b;hp=0000000000000000000000000000000000000000;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/vendor/drupal/console-core/src/Command/Debug/SiteCommand.php b/vendor/drupal/console-core/src/Command/Debug/SiteCommand.php new file mode 100644 index 000000000..b496b2aa3 --- /dev/null +++ b/vendor/drupal/console-core/src/Command/Debug/SiteCommand.php @@ -0,0 +1,125 @@ +configurationManager = $configurationManager; + parent::__construct(); + } + + /** + * @{@inheritdoc} + */ + public function configure() + { + $this + ->setName('debug:site') + ->setDescription($this->trans('commands.debug.site.description')) + ->addArgument( + 'target', + InputArgument::OPTIONAL, + $this->trans('commands.debug.site.options.target'), + null + ) + ->addArgument( + 'property', + InputArgument::OPTIONAL, + $this->trans('commands.debug.site.options.property'), + null + ) + ->setHelp($this->trans('commands.debug.site.help')) + ->setAliases(['dsi']); + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $sites = $this->configurationManager->getSites(); + + if (!$sites) { + $this->getIo()->warning($this->trans('commands.debug.site.messages.invalid-sites')); + + return 0; + } + + $target = $input->getArgument('target'); + if (!$target) { + foreach ($sites as $key => $site) { + $environments = array_keys($site); + unset($environments[0]); + + $environments = array_map( + function ($element) use ($key) { + return $key . '.' . $element; + }, + $environments + ); + + $this->getIo()->info($key); + $this->getIo()->listing($environments); + } + + return 0; + } + + $targetConfig = $this->configurationManager->readTarget($target); + if (!$targetConfig) { + $this->getIo()->error($this->trans('commands.debug.site.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]; + } + + $this->getIo()->writeln($val); + return 0; + } + + $this->getIo()->info($target); + $dumper = new Dumper(); + $this->getIo()->writeln($dumper->dump($targetConfig, 4, 2)); + + return 0; + } +}