Skip to content
Snippets Groups Projects
Commit 1f9b934a authored by jurgenhaas's avatar jurgenhaas
Browse files

docker/l3d#58 Move project settings out of composer.json

parent e06d1abc
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,11 @@ final class Config {
private static $values;
/**
* @var string
*/
private $component;
/**
* Config constructor.
*
......@@ -20,6 +25,7 @@ final class Config {
* @param \LakeDrops\Component\Dotenv\Dotenv $env
*/
public function __construct(string $component, array $default_values, Dotenv $env) {
$this->component = $component;
$this->init();
$componentValues = self::$values[$component] ?? [];
self::$values[$component] = $env->replaceEnvironmentVariables(NestedArray::mergeDeep($default_values, $componentValues));
......@@ -38,4 +44,32 @@ final class Config {
}
}
/**
* @param array $values
* @param array $keys
*
* @return mixed|null
*/
private function readValueFromArray($values, $keys) {
$key = array_shift($keys);
if (!isset($values[$key])) {
return NULL;
}
if (empty($keys)) {
return $values[$key];
}
return $this->readValueFromArray($values[$key], $keys);
}
/**
* @param $path
*
* @return mixed|null
*/
public function readValue($path) {
$parts = explode('/', $path);
return $this->readValueFromArray(self::$values[$this->component], $parts);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment