-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
[DependencyInjection] Add an env function to DI expression language #45450
Conversation
@@ -1586,7 +1586,7 @@ private function getExpressionLanguage(): ExpressionLanguage | |||
if (!class_exists(\Symfony\Component\ExpressionLanguage\ExpressionLanguage::class)) { | |||
throw new LogicException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.'); | |||
} | |||
$this->expressionLanguage = new ExpressionLanguage(null, $this->expressionLanguageProviders); | |||
$this->expressionLanguage = new ExpressionLanguage(null, $this->expressionLanguageProviders, null, \Closure::fromCallable([$this, 'getEnv'])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only way I found to allow the expression language to fetch an env variable outside of a dumped container because of the getEnv
visibility but maybe we could make the method public instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, I like it :)
Thank you @jvasseur. |
…xpression function (jvasseur) This PR was merged into the 6.1 branch. Discussion ---------- [DependencyInjection] Add documentation for the env DI expression function Doc PR for symfony/symfony#45450 Commits ------- bcbf1f3 Add documentation for the env DI expresion function
This add an
env
function to the DI expression language provider to ease creating expressions that depends on an environment variable.