@@ -1026,34 +1026,47 @@ public function getExpressionLanguageProviders()
1026
1026
}
1027
1027
1028
1028
/**
1029
- * Resolves env parameter placeholders in a string.
1029
+ * Resolves env parameter placeholders in a string or an array .
1030
1030
*
1031
- * @param string $string The string to resolve
1031
+ * @param mixed $value The value to resolve
1032
1032
* @param string|null $format A sprintf() format to use as replacement for env placeholders or null to use the default parameter format
1033
1033
* @param array &$usedEnvs Env vars found while resolving are added to this array
1034
1034
*
1035
1035
* @return string The string with env parameters resolved
1036
1036
*/
1037
- public function resolveEnvPlaceholders ($ string , $ format = null , array &$ usedEnvs = null )
1037
+ public function resolveEnvPlaceholders ($ value , $ format = null , array &$ usedEnvs = null )
1038
1038
{
1039
- $ bag = $ this ->getParameterBag ();
1040
- $ envPlaceholders = $ bag instanceof EnvPlaceholderParameterBag ? $ bag ->getEnvPlaceholders () : $ this ->envPlaceholders ;
1041
-
1042
1039
if (null === $ format ) {
1043
1040
$ format = '%%env(%s)%% ' ;
1044
1041
}
1045
1042
1043
+ if (is_array ($ value )) {
1044
+ $ result = array ();
1045
+ foreach ($ value as $ k => $ v ) {
1046
+ $ result [$ this ->resolveEnvPlaceholders ($ k , $ format , $ usedEnvs )] = $ this ->resolveEnvPlaceholders ($ v , $ format , $ usedEnvs );
1047
+ }
1048
+
1049
+ return $ result ;
1050
+ }
1051
+
1052
+ if (!is_string ($ value )) {
1053
+ return $ value ;
1054
+ }
1055
+
1056
+ $ bag = $ this ->getParameterBag ();
1057
+ $ envPlaceholders = $ bag instanceof EnvPlaceholderParameterBag ? $ bag ->getEnvPlaceholders () : $ this ->envPlaceholders ;
1058
+
1046
1059
foreach ($ envPlaceholders as $ env => $ placeholders ) {
1047
1060
foreach ($ placeholders as $ placeholder ) {
1048
- if (false !== stripos ($ string , $ placeholder )) {
1049
- $ string = str_ireplace ($ placeholder , sprintf ($ format , $ env ), $ string );
1061
+ if (false !== stripos ($ value , $ placeholder )) {
1062
+ $ value = str_ireplace ($ placeholder , sprintf ($ format , $ env ), $ value );
1050
1063
$ usedEnvs [$ env ] = $ env ;
1051
1064
$ this ->envCounters [$ env ] = isset ($ this ->envCounters [$ env ]) ? 1 + $ this ->envCounters [$ env ] : 1 ;
1052
1065
}
1053
1066
}
1054
1067
}
1055
1068
1056
- return $ string ;
1069
+ return $ value ;
1057
1070
}
1058
1071
1059
1072
/**
0 commit comments