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

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

parent 1dd2fd0e
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@ use Composer\Composer;
use Composer\IO\IOInterface;
use Composer\Package\PackageInterface;
use Composer\Script\Event;
use LakeDrops\Component\Dotenv\Dotenv;
use Symfony\Component\Console\Input\InputInterface;
/**
......@@ -55,6 +56,11 @@ abstract class BaseHandler implements BaseHandlerInterface {
*/
protected $drupalCorePackage;
/**
* @var \LakeDrops\Component\Dotenv\Dotenv
*/
protected $env;
/**
* Handler constructor.
*
......@@ -66,7 +72,9 @@ abstract class BaseHandler implements BaseHandlerInterface {
public function __construct(Composer $composer, IOInterface $io) {
$this->composer = $composer;
$this->io = $io;
$this->config = new Config($this->configId(), $this->configDefault());
$this->env = new Dotenv('docker4drupal', $this->io);
$this->config = new Config($this->configId(), $this->configDefault(), $this->env);
$this->postInit();
}
/**
......@@ -76,6 +84,11 @@ abstract class BaseHandler implements BaseHandlerInterface {
return [];
}
/**
* May be overwritten by implementing classes.
*/
protected function postInit(): void {}
/**
* {@inheritdoc}
*/
......
......@@ -2,6 +2,7 @@
namespace LakeDrops\Component\Composer;
use LakeDrops\Component\Dotenv\Dotenv;
use Symfony\Component\Yaml\Yaml;
/**
......@@ -16,11 +17,12 @@ final class Config {
*
* @param string $component
* @param array $default_values
* @param \LakeDrops\Component\Dotenv\Dotenv $env
*/
public function __construct(string $component, array $default_values) {
public function __construct(string $component, array $default_values, Dotenv $env) {
$this->init();
$componentValues = self::$values[$component] ?? [];
self::$values[$component] = NestedArray::mergeDeep($default_values, $componentValues);
self::$values[$component] = $env->replaceEnvironmentVariables(NestedArray::mergeDeep($default_values, $componentValues));
}
/**
......
......@@ -26,6 +26,7 @@
"require": {
"php": ">=7.2",
"ext-json": "*",
"lakedrops/dotenv": "^1.5||dev-master",
"symfony/yaml": "^3.4||^4.4||^5.0"
},
"require-dev": {
......
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