function FixtureManipulator::addConfig
Modifies the project root's composer.json properties.
Parameters
array $additional_config: The configuration to add.
See also
\Composer\Command\ConfigCommand
File
-
core/
modules/ package_manager/ tests/ modules/ fixture_manipulator/ src/ FixtureManipulator.php, line 307
Class
- FixtureManipulator
- Manipulates a test fixture using Composer commands.
Namespace
Drupal\fixture_manipulatorCode
public function addConfig(array $additional_config) : self {
if (empty($additional_config)) {
throw new \InvalidArgumentException('No config to add.');
}
if (!$this->committingChanges) {
$this->queueManipulation('addConfig', func_get_args());
return $this;
}
$clean_value = function ($value) {
return $value === FALSE ? 'false' : $value;
};
foreach ($additional_config as $key => $value) {
$command = [
'config',
];
if (is_array($value)) {
$value = json_encode($value, JSON_UNESCAPED_SLASHES);
$command[] = '--json';
}
else {
$value = $clean_value($value);
}
$command[] = $key;
$command[] = $value;
$this->runComposerCommand($command);
}
$this->runComposerCommand([
'update',
'--lock',
]);
return $this;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.