From a2ea6df93805408d3ce6bb1fc1b1e29eaa37713a Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Thu, 8 Oct 2015 20:30:51 -0400 Subject: [PATCH] apiExplorer - Encorage 'return' to be an array for php & js --- templates/CRM/Admin/Page/APIExplorer.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/templates/CRM/Admin/Page/APIExplorer.js b/templates/CRM/Admin/Page/APIExplorer.js index 77a7581e92..4b1bc15d95 100644 --- a/templates/CRM/Admin/Page/APIExplorer.js +++ b/templates/CRM/Admin/Page/APIExplorer.js @@ -559,22 +559,25 @@ }; smartyPhp = []; $.each(params, function(key, value) { - var js = JSON.stringify(value); + var json = JSON.stringify(value), + // Encourage 'return' to be an array - at least in php & js + js = key === 'return' ? JSON.stringify(evaluate(value, true)) : json, + php = key === 'return' ? phpFormat(evaluate(value, true)) : phpFormat(value); if (!(i++)) { q.php += ", array(\n"; q.json += ", {\n"; } else { q.json += ",\n"; } - q.php += " '" + key + "' => " + phpFormat(value) + ",\n"; + q.php += " '" + key + "' => " + php + ",\n"; q.json += " \"" + key + '": ' + js; // smarty already defaults to sequential if (key !== 'sequential') { - q.smarty += ' ' + key + '=' + smartyFormat(value, js, key); + q.smarty += ' ' + key + '=' + smartyFormat(value, json, key); } // FIXME: This is not totally correct cli syntax - q.drush += key + '=' + js + ' '; - q.wpcli += key + '=' + js + ' '; + q.drush += key + '=' + json + ' '; + q.wpcli += key + '=' + json + ' '; }); if (i) { q.php += ")"; -- 2.25.1