Fixed querying of default config values, and fix source display for them, and fix bools to show as bools, fixes #11302
parent
5c3d8f35db
commit
91b7b0ff3b
|
@ -274,8 +274,21 @@ EOT
|
||||||
// show the value if no value is provided
|
// show the value if no value is provided
|
||||||
if ([] === $input->getArgument('setting-value') && !$input->getOption('unset')) {
|
if ([] === $input->getArgument('setting-value') && !$input->getOption('unset')) {
|
||||||
$properties = self::CONFIGURABLE_PACKAGE_PROPERTIES;
|
$properties = self::CONFIGURABLE_PACKAGE_PROPERTIES;
|
||||||
|
$propertiesDefaults = [
|
||||||
|
'type' => 'library',
|
||||||
|
'description' => '',
|
||||||
|
'homepage' => '',
|
||||||
|
'minimum-stability' => 'stable',
|
||||||
|
'prefer-stable' => false,
|
||||||
|
'keywords' => [],
|
||||||
|
'license' => [],
|
||||||
|
'suggest' => [],
|
||||||
|
'extra' => [],
|
||||||
|
];
|
||||||
$rawData = $this->configFile->read();
|
$rawData = $this->configFile->read();
|
||||||
$data = $this->config->all();
|
$data = $this->config->all();
|
||||||
|
$source = $this->config->getSourceOfValue($settingKey);
|
||||||
|
|
||||||
if (Preg::isMatch('/^repos?(?:itories)?(?:\.(.+))?/', $settingKey, $matches)) {
|
if (Preg::isMatch('/^repos?(?:itories)?(?:\.(.+))?/', $settingKey, $matches)) {
|
||||||
if (!isset($matches[1]) || $matches[1] === '') {
|
if (!isset($matches[1]) || $matches[1] === '') {
|
||||||
$value = $data['repositories'] ?? [];
|
$value = $data['repositories'] ?? [];
|
||||||
|
@ -313,17 +326,21 @@ EOT
|
||||||
$value = $this->config->get($settingKey, $input->getOption('absolute') ? 0 : Config::RELATIVE_PATHS);
|
$value = $this->config->get($settingKey, $input->getOption('absolute') ? 0 : Config::RELATIVE_PATHS);
|
||||||
} elseif (isset($rawData[$settingKey]) && in_array($settingKey, $properties, true)) {
|
} elseif (isset($rawData[$settingKey]) && in_array($settingKey, $properties, true)) {
|
||||||
$value = $rawData[$settingKey];
|
$value = $rawData[$settingKey];
|
||||||
|
$source = $this->configFile->getPath();
|
||||||
|
} elseif (isset($propertiesDefaults[$settingKey])) {
|
||||||
|
$value = $propertiesDefaults[$settingKey];
|
||||||
|
$source = 'defaults';
|
||||||
} else {
|
} else {
|
||||||
throw new \RuntimeException($settingKey.' is not defined');
|
throw new \RuntimeException($settingKey.' is not defined');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($value)) {
|
if (is_array($value) || is_bool($value)) {
|
||||||
$value = JsonFile::encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
$value = JsonFile::encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sourceOfConfigValue = '';
|
$sourceOfConfigValue = '';
|
||||||
if ($input->getOption('source')) {
|
if ($input->getOption('source')) {
|
||||||
$sourceOfConfigValue = ' (' . $this->config->getSourceOfValue($settingKey) . ')';
|
$sourceOfConfigValue = ' (' . $source . ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->getIO()->write($value . $sourceOfConfigValue, true, IOInterface::QUIET);
|
$this->getIO()->write($value . $sourceOfConfigValue, true, IOInterface::QUIET);
|
||||||
|
|
Loading…
Reference in New Issue