Env var maps to undefined constant.

When I try to use a constant as an environment variable, as described in the blog item, 
I run into the following problem.

Env var "SOME_CONST" maps to undefined constant "App\\Util\\SomeClass::SOME_CONST".

The proposed solution works for me, however, I'm not sure if this is the best and conform Symfony standards.

Blog:
https://symfony.com/blog/new-in-symfony-3-4-advanced-environment-variables
This commit is contained in:
dsmink 2018-02-09 13:27:46 +01:00 committed by Nicolas Grekas
parent a41874f6a6
commit bdf9efc78e

View File

@ -110,11 +110,13 @@ class EnvVarProcessor implements EnvVarProcessorInterface
}
if ('const' === $prefix) {
$env = \str_replace("\\\\","\\", $env);
if (!defined($env)) {
throw new RuntimeException(sprintf('Env var "%s" maps to undefined constant "%s".', $name, $env));
}
return constant($name);
return constant($env);
}
if ('base64' === $prefix) {