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