@@ -1026,34 +1026,47 @@ public function getExpressionLanguageProviders()
10261026 }
10271027
10281028 /**
1029- * Resolves env parameter placeholders in a string.
1029+ * Resolves env parameter placeholders in a string or an array .
10301030 *
1031- * @param string $string The string to resolve
1031+ * @param mixed $value The value to resolve
10321032 * @param string|null $format A sprintf() format to use as replacement for env placeholders or null to use the default parameter format
10331033 * @param array &$usedEnvs Env vars found while resolving are added to this array
10341034 *
10351035 * @return string The string with env parameters resolved
10361036 */
1037- public function resolveEnvPlaceholders ($ string , $ format = null , array &$ usedEnvs = null )
1037+ public function resolveEnvPlaceholders ($ value , $ format = null , array &$ usedEnvs = null )
10381038 {
1039- $ bag = $ this ->getParameterBag ();
1040- $ envPlaceholders = $ bag instanceof EnvPlaceholderParameterBag ? $ bag ->getEnvPlaceholders () : $ this ->envPlaceholders ;
1041-
10421039 if (null === $ format ) {
10431040 $ format = '%%env(%s)%% ' ;
10441041 }
10451042
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+
10461059 foreach ($ envPlaceholders as $ env => $ placeholders ) {
10471060 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 );
10501063 $ usedEnvs [$ env ] = $ env ;
10511064 $ this ->envCounters [$ env ] = isset ($ this ->envCounters [$ env ]) ? 1 + $ this ->envCounters [$ env ] : 1 ;
10521065 }
10531066 }
10541067 }
10551068
1056- return $ string ;
1069+ return $ value ;
10571070 }
10581071
10591072 /**
0 commit comments