@@ -1028,9 +1028,11 @@ public function getExpressionLanguageProviders()
1028
1028
/**
1029
1029
* Resolves env parameter placeholders in a string or an array.
1030
1030
*
1031
- * @param mixed $value The value to resolve
1032
- * @param string|null $format A sprintf() format to use as replacement for env placeholders or null to use the default parameter format
1033
- * @param array &$usedEnvs Env vars found while resolving are added to this array
1031
+ * @param mixed $value The value to resolve
1032
+ * @param string|true|null $format A sprintf() format returning the replacement for each env var name or
1033
+ * null to resolve back to the original "%env(VAR)%" format or
1034
+ * true to resolve to the actual values of the referenced env vars
1035
+ * @param array &$usedEnvs Env vars found while resolving are added to this array
1034
1036
*
1035
1037
* @return string The string with env parameters resolved
1036
1038
*/
@@ -1054,12 +1056,20 @@ public function resolveEnvPlaceholders($value, $format = null, array &$usedEnvs
1054
1056
}
1055
1057
1056
1058
$ bag = $ this ->getParameterBag ();
1059
+ if (true === $ format ) {
1060
+ $ value = $ bag ->resolveValue ($ value );
1061
+ }
1057
1062
$ envPlaceholders = $ bag instanceof EnvPlaceholderParameterBag ? $ bag ->getEnvPlaceholders () : $ this ->envPlaceholders ;
1058
1063
1059
1064
foreach ($ envPlaceholders as $ env => $ placeholders ) {
1060
1065
foreach ($ placeholders as $ placeholder ) {
1061
1066
if (false !== stripos ($ value , $ placeholder )) {
1062
- $ value = str_ireplace ($ placeholder , sprintf ($ format , $ env ), $ value );
1067
+ if (true === $ format ) {
1068
+ $ resolved = $ bag ->escapeValue ($ this ->getEnv ($ env ));
1069
+ } else {
1070
+ $ resolved = sprintf ($ format , $ env );
1071
+ }
1072
+ $ value = str_ireplace ($ placeholder , $ resolved , $ value );
1063
1073
$ usedEnvs [$ env ] = $ env ;
1064
1074
$ this ->envCounters [$ env ] = isset ($ this ->envCounters [$ env ]) ? 1 + $ this ->envCounters [$ env ] : 1 ;
1065
1075
}
0 commit comments