9use Symfony\Component\Console\Command\Command;
10use Symfony\Component\Console\Input\InputArgument;
11use Symfony\Component\Console\Input\InputInterface;
12use Symfony\Component\Console\Output\OutputInterface;
41 if (!file_exists(
$name) || !is_readable(
$name)) {
42 throw new \InvalidArgumentException(
43 "Config-file '$name' does not exist or is not readable."
46 $json = json_decode(file_get_contents(
$name), JSON_OBJECT_AS_ARRAY);
47 if (!is_array($json)) {
48 throw new \InvalidArgumentException(
49 "Could not find JSON-array in '$name'."
58 $replacer =
function ($subject, $path, $value) use (&$replacer) {
59 if (count($path) === 0) {
62 $cur = array_shift($path);
63 $subject[$cur] = $replacer($subject[$cur] ?? [], $path, $value);
67 foreach ($overwrites as $path => $value) {
68 $path = explode(
".", $path);
69 $json = $replacer($json, $path, $value);
77 if (in_array(
$name[0], [
"/",
"\\"])) {
80 return $this->base_dir .
"/" .
$name;
An exception for terminatinating execution or to throw for unit testing.
Read a json-formatted config from a file and overwrite some fields.
__construct($base_dir=null)
applyOverwrites(array $json, array $overwrites)
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...