Skip to content

Commit bd22067

Browse files
committed
Update config
1 parent 70d41b7 commit bd22067

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

config/config-dev.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@
139139
$body = $template->render($mapVariables);
140140

141141
$prefix = "";
142-
if (Psr11::environment()->getCurrentConfig() != "prod") {
143-
$prefix = "[" . Psr11::environment()->getCurrentConfig() . "] ";
142+
if (Psr11::environment()->getCurrentEnvironment() != "prod") {
143+
$prefix = "[" . Psr11::environment()->getCurrentEnvironment() . "] ";
144144
}
145145
return new Envelope(Psr11::container()->get('EMAIL_TRANSACTIONAL_FROM'), $to, $prefix . $subject, $body, true);
146146
},

src/Psr11.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
namespace RestReferenceArchitecture;
44

55
use ByJG\Cache\Psr16\FileSystemCacheEngine;
6-
use ByJG\Cache\Psr16\NoCacheEngine;
76
use ByJG\Config\Container;
87
use ByJG\Config\Definition;
8+
use ByJG\Config\Environment;
99
use ByJG\Config\Exception\ConfigException;
1010
use ByJG\Config\Exception\ConfigNotFoundException;
1111
use ByJG\Config\Exception\InvalidDateException;
@@ -40,14 +40,17 @@ public static function container($env = null): ?Container
4040
*/
4141
public static function environment(): ?Definition
4242
{
43+
$dev = new Environment('dev');
44+
$test = new Environment('test', [$dev]);
45+
$staging = new Environment('staging', [$dev], new FileSystemCacheEngine());
46+
$prod = new Environment('prod', [$staging, $dev], new FileSystemCacheEngine());
47+
4348
if (is_null(self::$definition)) {
4449
self::$definition = (new Definition())
45-
->addConfig('dev')
46-
->addConfig('test' , inheritFrom: ['dev'])
47-
->addConfig('staging', inheritFrom: ['dev'])
48-
->addConfig('prod', inheritFrom: ['staging', 'dev'])
49-
->setCache(['dev', 'test'], new NoCacheEngine())
50-
->setCache(['prod', 'staging'], new FileSystemCacheEngine())
50+
->addEnvironment($dev)
51+
->addEnvironment($test)
52+
->addEnvironment($staging)
53+
->addEnvironment($prod)
5154
;
5255
}
5356

tests/Functional/Rest/BaseApiTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function getPsr7Request(): Request
4040
public function resetDb()
4141
{
4242
if (!self::$databaseReset) {
43-
if (Psr11::environment()->getCurrentConfig() != "test") {
43+
if (Psr11::environment()->getCurrentEnvironment() != "test") {
4444
throw new Exception("This test can only be executed in test environment");
4545
}
4646
Migration::registerDatabase(MySqlDatabase::class);

0 commit comments

Comments
 (0)