Skip to content

Commit

Permalink
Merge pull request #22382 from colemanw/api4ExplorerFormatArrayParams
Browse files Browse the repository at this point in the history
APIv4 Explorer - Format array params using add methods instead of set
  • Loading branch information
colemanw authored Jan 5, 2022
2 parents 0e43966 + 21f5691 commit 120d5b1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ang/api4Explorer/Explorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,7 @@
// Format oop params
function formatOOP(entity, action, params, indent) {
var info = getEntity(entity),
arrayParams = ['groupBy', 'records'],
newLine = "\n" + _.repeat(' ', indent),
code = '\\' + info.class + '::' + action + '(',
perm = params.checkPermissions === false ? 'FALSE' : '';
Expand All @@ -804,6 +805,10 @@
val = phpFormat(index) + ', ' + phpFormat(item, 2 + indent);
code += newLine + "->add" + ucfirst(key).replace(/s$/, '') + '(' + val + ')';
});
} else if (_.includes(arrayParams, key)) {
_.each(param, function(item) {
code += newLine + "->add" + ucfirst(key).replace(/s$/, '') + '(' + phpFormat(item, 2 + indent) + ')';
});
} else if (key === 'where') {
_.each(param, function (clause) {
if (clause[0] === 'AND' || clause[0] === 'OR' || clause[0] === 'NOT') {
Expand Down

0 comments on commit 120d5b1

Please sign in to comment.