@@ -2030,18 +2030,20 @@ private function resolveRuntimeReference($args, $regex, $func)
2030
2030
$ newArgs = [];
2031
2031
2032
2032
foreach ($ args as $ key => $ arg ) {
2033
+ $ newArgs [$ key ] = $ arg ;
2033
2034
preg_match_all ($ regex , $ arg , $ matches );
2034
2035
if (!empty ($ matches [0 ])) {
2035
- $ fullMatch = $ matches [0 ][0 ];
2036
- $ refVariable = $ matches [1 ][0 ];
2037
- unset($ matches );
2038
- $ replacement = "{$ func }( \"{$ refVariable }\") " ;
2036
+ foreach ($ matches [0 ] as $ matchKey => $ fullMatch ) {
2037
+ $ refVariable = $ matches [1 ][$ matchKey ];
2039
2038
2040
- $ outputArg = $ this ->processQuoteBreaks ($ fullMatch , $ arg , $ replacement );
2041
- $ newArgs [$ key ] = $ outputArg ;
2039
+ $ replacement = $ this ->getReplacement ($ func , $ refVariable );
2040
+
2041
+ $ outputArg = $ this ->processQuoteBreaks ($ fullMatch , $ newArgs [$ key ], $ replacement );
2042
+ $ newArgs [$ key ] = $ outputArg ;
2043
+ }
2044
+ unset($ matches );
2042
2045
continue ;
2043
2046
}
2044
- $ newArgs [$ key ] = $ arg ;
2045
2047
}
2046
2048
2047
2049
// override passed in args for use later.
@@ -2313,4 +2315,20 @@ private function parseUserInput($userInput)
2313
2315
2314
2316
return $ this ->addUniquenessFunctionCall ($ userInput );
2315
2317
}
2318
+
2319
+ /**
2320
+ * Supports fallback for BACKEND URL
2321
+ *
2322
+ * @param string $func
2323
+ * @param string $refVariable
2324
+ * @return string
2325
+ */
2326
+ private function getReplacement ($ func , $ refVariable ): string
2327
+ {
2328
+ if ($ refVariable === 'MAGENTO_BACKEND_BASE_URL ' ) {
2329
+ return "( {$ func }( \"{$ refVariable }\") ? rtrim( {$ func }( \"{$ refVariable }\"), \"/ \") : \"\") " ;
2330
+ }
2331
+
2332
+ return "{$ func }( \"{$ refVariable }\") " ;
2333
+ }
2316
2334
}
0 commit comments