-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #89 from City-of-Helsinki/UHF-X-environment-normal…
…izer Environment normalizer
- Loading branch information
Showing
5 changed files
with
63 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Drupal\helfi_api_base\Environment; | ||
|
||
/** | ||
* A helper trait to deal with environments. | ||
*/ | ||
trait EnvironmentTrait { | ||
|
||
/** | ||
* Temporary mapping function to match APP_ENV with environment resolver. | ||
* | ||
* @param string $environment | ||
* APP_ENV or environment name. | ||
* | ||
* @return null|string | ||
* The environment name. | ||
*/ | ||
protected function normalizeEnvironmentName(string $environment) : ? string { | ||
// Some environments have an incorrect APP_ENV value, like 'production', | ||
// 'staging' and 'testing' instead of 'local', 'test,' 'stage' and 'prod'. | ||
// Map all known environment name variations to match environment resolver. | ||
$environments = [ | ||
'testing' => 'test', | ||
'staging' => 'stage', | ||
'production' => 'prod', | ||
]; | ||
|
||
if (array_key_exists($environment, $environments)) { | ||
return $environments[$environment]; | ||
} | ||
return $environment; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters