Skip to content

Commit

Permalink
[debug:config] Add show-overridden flag. (#3837)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmolivas committed Mar 21, 2018
1 parent e6bf8a2 commit 0368218
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/Command/Debug/ConfigCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Drupal\Component\Serialization\Yaml;
use Drupal\Core\Config\CachedStorage;
Expand Down Expand Up @@ -55,6 +56,12 @@ protected function configure()
InputArgument::OPTIONAL,
$this->trans('commands.debug.config.arguments.name')
)
->addOption(
'show-overridden',
null,
InputOption::VALUE_NONE,
$this->trans('commands.debug.config.options.show-overridden')
)
->setAliases(['dc']);
}

Expand All @@ -64,10 +71,12 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output)
{
$configName = $input->getArgument('name');
$showOverridden = $input->getOption('show-overridden');

if (!$configName) {
$this->getAllConfigurations();
} else {
$this->getConfigurationByName($configName);
$this->getConfigurationByName($configName, $showOverridden);
}
}

Expand All @@ -88,16 +97,25 @@ private function getAllConfigurations()
}

/**
* @param $config_name String
* @param $config_name String
* @param $showOverridden bool
*/
private function getConfigurationByName($config_name)
private function getConfigurationByName($config_name, $showOverridden = false)
{
if ($this->configStorage->exists($config_name)) {
$tableHeader = [
$config_name,
];

$configuration = $this->configStorage->read($config_name);
if ($showOverridden) {
$configurationKeys = array_keys($configuration);
foreach ($configurationKeys as $configurationKey) {
$configuration[$configurationKey] = $this->configFactory
->get($config_name)
->get($configurationKey);
}
}

$configurationEncoded = Yaml::encode($configuration);
$tableRows = [];
$tableRows[] = [
Expand Down

0 comments on commit 0368218

Please sign in to comment.