@@ -84,23 +84,22 @@ private function getResolvedActionsWithArgs($arguments, $actionReferenceKey)
84
84
// $regexPattern match on: $matches[0] {{section.element(arg.field)}}
85
85
// $matches[1] = section.element
86
86
// $matches[2] = arg.field
87
- $ regexPattern = '/{{([\w.]+)\(*([\w.$ \']+)*\)*}}/ ' ;
88
-
87
+ $ regexPattern ='/{{([\w.]+)\(?([\w.$ \',\s]+)?\)?}}/ ' ;
89
88
foreach ($ this ->parsedActions as $ action ) {
90
89
$ varAttributes = array_intersect (self ::VAR_ATTRIBUTES , array_keys ($ action ->getCustomActionAttributes ()));
91
90
$ newActionAttributes = [];
91
+
92
92
if (!empty ($ varAttributes )) {
93
93
// 1 check to see if we have pertinent var
94
94
foreach ($ varAttributes as $ varAttribute ) {
95
95
$ attributeValue = $ action ->getCustomActionAttributes ()[$ varAttribute ];
96
96
preg_match_all ($ regexPattern , $ attributeValue , $ matches );
97
-
98
97
if (empty ($ matches [0 ])) {
99
98
continue ;
100
99
}
101
100
102
101
//get rid of full match {{arg.field(arg.field)}}
103
- unset ($ matches[ 0 ] );
102
+ array_shift ($ matches );
104
103
105
104
$ newActionAttributes [$ varAttribute ] = $ this ->replaceAttributeArguments (
106
105
$ arguments ,
@@ -132,36 +131,67 @@ private function getResolvedActionsWithArgs($arguments, $actionReferenceKey)
132
131
*/
133
132
private function replaceAttributeArguments ($ arguments , $ attributeValue , $ matches )
134
133
{
135
- $ matchParametersKey = 2 ;
136
- $ newAttributeVal = $ attributeValue ;
134
+ list ($ mainValueList , $ possibleArgumentsList ) = $ matches ;
137
135
138
- foreach ($ matches as $ key => $ match ) {
139
- foreach ($ match as $ variable ) {
140
- if (empty ($ variable )) {
141
- continue ;
142
- }
143
- // Truncate arg.field into arg
144
- $ variableName = strstr ($ variable , '. ' , true );
145
- // Check if arguments has a mapping for the given variableName
146
- if (!array_key_exists ($ variableName , $ arguments )) {
147
- continue ;
148
- }
149
- $ isPersisted = strstr ($ arguments [$ variableName ], '$ ' );
150
- if ($ isPersisted ) {
151
- $ newAttributeVal = $ this ->replacePersistedArgument (
152
- $ arguments [$ variableName ],
153
- $ attributeValue ,
154
- $ variable ,
155
- $ variableName ,
156
- $ key == $ matchParametersKey ? true : false
157
- );
158
- } else {
159
- $ newAttributeVal = str_replace ($ variableName , $ arguments [$ variableName ], $ attributeValue );
160
- }
136
+ foreach ($ mainValueList as $ index => $ mainValue ) {
137
+ $ possibleArguments = $ possibleArgumentsList [$ index ];
138
+
139
+ $ attributeValue = $ this ->replaceAttributeArgumentInVariable ($ mainValue , $ arguments , $ attributeValue );
140
+
141
+ $ argumentList = array_filter (array_map ('trim ' , explode (', ' , $ possibleArguments )));
142
+
143
+ foreach ($ argumentList as $ argumentValue ) {
144
+ $ attributeValue = $ this ->replaceAttributeArgumentInVariable (
145
+ $ argumentValue ,
146
+ $ arguments ,
147
+ $ attributeValue ,
148
+ true
149
+ );
161
150
}
162
151
}
163
152
164
- return $ newAttributeVal ;
153
+ return $ attributeValue ;
154
+ }
155
+
156
+ /**
157
+ * Replace attribute arguments in variable.
158
+ *
159
+ * @param string $variable
160
+ * @param array $arguments
161
+ * @param string $attributeValue
162
+ * @param bool $isInnerArgument
163
+ * @return string
164
+ */
165
+ private function replaceAttributeArgumentInVariable (
166
+ $ variable ,
167
+ $ arguments ,
168
+ $ attributeValue ,
169
+ $ isInnerArgument = false
170
+ ) {
171
+ // Truncate arg.field into arg
172
+ $ variableName = strstr ($ variable , '. ' , true );
173
+ // Check if arguments has a mapping for the given variableName
174
+
175
+ if ($ variableName === false ) {
176
+ $ variableName = $ variable ;
177
+ }
178
+
179
+ if (!array_key_exists ($ variableName , $ arguments )) {
180
+ return $ attributeValue ;
181
+ }
182
+
183
+ $ isPersisted = strstr ($ arguments [$ variableName ], '$ ' );
184
+ if ($ isPersisted ) {
185
+ return $ this ->replacePersistedArgument (
186
+ $ arguments [$ variableName ],
187
+ $ attributeValue ,
188
+ $ variable ,
189
+ $ variableName ,
190
+ $ isInnerArgument
191
+ );
192
+ }
193
+
194
+ return str_replace ($ variableName , $ arguments [$ variableName ], $ attributeValue );
165
195
}
166
196
167
197
/**
0 commit comments