19declare(strict_types=1);
27use Symfony\Component\Console\Input\InputArgument;
28use Symfony\Component\Console\Input\InputInterface;
29use Symfony\Component\Console\Output\OutputInterface;
30use Seld\JsonLint\JsonParser;
58 if (!is_readable($name)) {
59 throw new \InvalidArgumentException(
60 "Config-file '$name' does not exist or is not readable."
63 $json = $this->json_parser->parse(
64 file_get_contents($name),
65 JsonParser::PARSE_TO_ASSOC | JsonParser::DETECT_KEY_CONFLICTS
68 if (!is_array($json)) {
69 throw new \InvalidArgumentException(
70 "Could not find JSON-array in '$name'."
79 $replacer =
function ($subject,
$path, $value) use (&$replacer) {
80 if (count(
$path) === 0) {
83 $cur = array_shift(
$path);
84 $subject[$cur] = $replacer($subject[$cur] ?? [],
$path, $value);
88 foreach ($overwrites as
$path => $value) {
90 $json = $replacer($json,
$path, $value);
98 if (in_array($name[0], [
"/",
"\\"])) {
101 return $this->base_dir .
"/" . $name;
Read a json-formatted config from a file and overwrite some fields.
applyOverwrites(array $json, array $overwrites)
__construct(JsonParser $json_parser, ?string $base_dir=null)
readConfigFile(string $name, array $overwrites=[])
TODO: We could use the "give me a transformation and I'll give you your result" pattern from th...
getRealFilename(string $name)
Tries to enumerate all preconditions for the given objective, where the ones that can be achieved (i....
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...