Skip to content

Commit

Permalink
Update config
Browse files Browse the repository at this point in the history
  • Loading branch information
byjg committed Dec 30, 2023
1 parent 70d41b7 commit bd22067
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions config/config-dev.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@
$body = $template->render($mapVariables);

$prefix = "";
if (Psr11::environment()->getCurrentConfig() != "prod") {
$prefix = "[" . Psr11::environment()->getCurrentConfig() . "] ";
if (Psr11::environment()->getCurrentEnvironment() != "prod") {
$prefix = "[" . Psr11::environment()->getCurrentEnvironment() . "] ";
}
return new Envelope(Psr11::container()->get('EMAIL_TRANSACTIONAL_FROM'), $to, $prefix . $subject, $body, true);
},
Expand Down
17 changes: 10 additions & 7 deletions src/Psr11.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace RestReferenceArchitecture;

use ByJG\Cache\Psr16\FileSystemCacheEngine;
use ByJG\Cache\Psr16\NoCacheEngine;
use ByJG\Config\Container;
use ByJG\Config\Definition;
use ByJG\Config\Environment;
use ByJG\Config\Exception\ConfigException;
use ByJG\Config\Exception\ConfigNotFoundException;
use ByJG\Config\Exception\InvalidDateException;
Expand Down Expand Up @@ -40,14 +40,17 @@ public static function container($env = null): ?Container
*/
public static function environment(): ?Definition
{
$dev = new Environment('dev');
$test = new Environment('test', [$dev]);
$staging = new Environment('staging', [$dev], new FileSystemCacheEngine());
$prod = new Environment('prod', [$staging, $dev], new FileSystemCacheEngine());

if (is_null(self::$definition)) {
self::$definition = (new Definition())
->addConfig('dev')
->addConfig('test' , inheritFrom: ['dev'])
->addConfig('staging', inheritFrom: ['dev'])
->addConfig('prod', inheritFrom: ['staging', 'dev'])
->setCache(['dev', 'test'], new NoCacheEngine())
->setCache(['prod', 'staging'], new FileSystemCacheEngine())
->addEnvironment($dev)
->addEnvironment($test)
->addEnvironment($staging)
->addEnvironment($prod)
;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/Rest/BaseApiTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function getPsr7Request(): Request
public function resetDb()
{
if (!self::$databaseReset) {
if (Psr11::environment()->getCurrentConfig() != "test") {
if (Psr11::environment()->getCurrentEnvironment() != "test") {
throw new Exception("This test can only be executed in test environment");
}
Migration::registerDatabase(MySqlDatabase::class);
Expand Down

0 comments on commit bd22067

Please sign in to comment.