1
0
Fork 0

Fix setting of scripts from config command, refs #7225

pull/7280/head
Jordi Boggiano 2018-04-13 13:10:22 +02:00
parent 5aff7dff70
commit 0ab843a058
3 changed files with 17 additions and 9 deletions

View File

@ -613,12 +613,12 @@ EOT
}
// handle script
if (preg_match('/^scripts\.(.+)/', $settingKey,$matches)){
if (preg_match('/^scripts\.(.+)/', $settingKey, $matches)){
if ($input->getOption('unset')) {
return $this->configSource->removeConfigSetting($settingKey);
return $this->configSource->removeProperty($settingKey);
}
return $this->configSource->addConfigSetting($settingKey, $values[0]);
return $this->configSource->addProperty($settingKey, count($values) > 1 ? $values : $values[0]);
}
throw new \InvalidArgumentException('Setting '.$settingKey.' does not exist or is not supported by this command');

View File

@ -135,10 +135,10 @@ class JsonConfigSource implements ConfigSourceInterface
public function addProperty($name, $value)
{
$this->manipulateJson('addProperty', $name, $value, function (&$config, $key, $val) {
if (substr($key, 0, 6) === 'extra.') {
if (substr($key, 0, 6) === 'extra.' || substr($key, 0, 8) === 'scripts.') {
$bits = explode('.', $key);
$last = array_pop($bits);
$arr = &$config['extra'];
$arr = &$config[reset($bits)];
foreach ($bits as $bit) {
if (!isset($arr[$bit])) {
$arr[$bit] = array();
@ -159,10 +159,10 @@ class JsonConfigSource implements ConfigSourceInterface
{
$authConfig = $this->authConfig;
$this->manipulateJson('removeProperty', $name, function (&$config, $key) {
if (substr($key, 0, 6) === 'extra.') {
if (substr($key, 0, 6) === 'extra.' || substr($key, 0, 8) === 'scripts.') {
$bits = explode('.', $key);
$last = array_pop($bits);
$arr = &$config['extra'];
$arr = &$config[reset($bits)];
foreach ($bits as $bit) {
if (!isset($arr[$bit])) {
return;

View File

@ -171,6 +171,10 @@ class JsonManipulator
return $this->addSubNode('extra', substr($name, 6), $value);
}
if (substr($name, 0, 8) === 'scripts.') {
return $this->addSubNode('scripts', substr($name, 8), $value);
}
return $this->addMainKey($name, $value);
}
@ -180,6 +184,10 @@ class JsonManipulator
return $this->removeSubNode('extra', substr($name, 6));
}
if (substr($name, 0, 8) === 'scripts.') {
return $this->removeSubNode('scripts', substr($name, 8));
}
return $this->removeMainKey($name);
}
@ -188,7 +196,7 @@ class JsonManipulator
$decoded = JsonFile::parseJson($this->contents);
$subName = null;
if (in_array($mainNode, array('config', 'extra')) && false !== strpos($name, '.')) {
if (in_array($mainNode, array('config', 'extra', 'scripts')) && false !== strpos($name, '.')) {
list($name, $subName) = explode('.', $name, 2);
}
@ -308,7 +316,7 @@ class JsonManipulator
}
$subName = null;
if (in_array($mainNode, array('config', 'extra')) && false !== strpos($name, '.')) {
if (in_array($mainNode, array('config', 'extra', 'scripts')) && false !== strpos($name, '.')) {
list($name, $subName) = explode('.', $name, 2);
}