Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for referencing environment variables in the config #2559

Merged
merged 3 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"hoa/regex": "1.17.01.13",
"jetbrains/phpstorm-stubs": "dev-master#beac237645ee7cf631f4386d21cffb016c8cde87",
"nette/bootstrap": "^3.0",
"nette/di": "^3.0.11",
"nette/di": "v3.1.x-dev",
"nette/finder": "^2.5",
"nette/neon": "^3.3.1",
"nette/schema": "^1.2.2",
Expand Down
17 changes: 9 additions & 8 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions conf/parametersSchema.neon
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ parametersSchema:
pro: structure([
dnsServers: schema(listOf(string()), min(1)),
])
env: arrayOf(string(), string())

# irrelevant Nette parameters
debugMode: bool()
Expand Down
2 changes: 2 additions & 0 deletions src/Command/CommandHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
use function error_get_last;
use function get_class;
use function getcwd;
use function getenv;
use function gettype;
use function implode;
use function ini_get;
Expand Down Expand Up @@ -212,6 +213,7 @@ public static function begin(
$defaultParameters = [
'rootDir' => $containerFactory->getRootDirectory(),
'currentWorkingDirectory' => $containerFactory->getCurrentWorkingDirectory(),
'env' => getenv(),
];

if (isset($projectConfig['parameters']['tmpDir'])) {
Expand Down
3 changes: 3 additions & 0 deletions src/DependencyInjection/ContainerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
use function count;
use function dirname;
use function extension_loaded;
use function getenv;
use function ini_get;
use function is_array;
use function is_dir;
Expand Down Expand Up @@ -105,6 +106,7 @@ public function create(
[
'rootDir' => $this->rootDirectory,
'currentWorkingDirectory' => $this->currentWorkingDirectory,
'env' => getenv(),
],
);

Expand Down Expand Up @@ -136,6 +138,7 @@ public function create(
$configurator->addDynamicParameters([
'analysedPaths' => $analysedPaths,
'analysedPathsFromConfig' => $analysedPathsFromConfig,
'env' => getenv(),
]);
$configurator->addConfig($this->configDirectory . '/config.neon');
foreach ($additionalConfigFiles as $additionalConfigFile) {
Expand Down
2 changes: 2 additions & 0 deletions src/DependencyInjection/LoaderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Nette\DI\Config\Loader;
use PHPStan\File\FileHelper;
use function getenv;

class LoaderFactory
{
Expand All @@ -25,6 +26,7 @@ public function createLoader(): Loader
$loader->setParameters([
'rootDir' => $this->rootDir,
'currentWorkingDirectory' => $this->currentWorkingDirectory,
'env' => getenv(),
]);

return $loader;
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/NeonAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
class NeonAdapter implements Adapter
{

public const CACHE_KEY = 'v18-parameters-schema';
public const CACHE_KEY = 'v19-env';

private const PREVENT_MERGING_SUFFIX = '!';

Expand Down