For some reason, v8 scripting is having no effect over the API calls.
I have installed DreamFactory manually, so I was wondering if it's perhaps to do with the V8 php mod I'm using (0.4.1)
I've previously installed DF using Bitnami on other servers and have written V8 scripts in the past, so I'm relatively sure I'm doing everything correctly.
Just to give a little more info on this. lodash doesn't seem to be working for some reason, so I'm now using the sample code with a standard for loop on post process of table{name} GET:
// A script that is triggered by a GET on /api/v2/db/_table/. Runs after the db call is made. var lodash = require("lodash.min.js"); if (event.response.content.resource) { // outputs to file in storage/log of dreamfactory install directory
//****************** Post-processing script on a table ******************
// The script adds a new field to each record in the response.for (var i = 0; i < event.response.content.resource.length; i++ ) {
event.response.content.resource[i].extraField = 'Feed the dog.';
}
var_dump(event.response.content);
}
The output in dreamfactory.log is as follows:
[2016-02-25 13:16:07] local.DEBUG: Resource event: d7db.table.{tablename}.get.post_process
[2016-02-25 13:16:48] local.DEBUG: Resource event: system.event.post.pre_process
[2016-02-25 13:16:48] local.DEBUG: Resource event: system.event.post.post_process
[2016-02-25 13:16:48] local.DEBUG: Resource event: system.event.get.pre_process
[2016-02-25 13:16:48] local.DEBUG: Resource event: system.event.get.post_process
[2016-02-25 13:16:53] local.DEBUG: Resource event: d7db.table.{tablename}.get.pre_process
[2016-02-25 13:16:53] local.DEBUG: Resource event: d7db.table.actions.get.preprocess
[2016-02-25 13:16:53] local.DEBUG: Resource event: d7db.table.actions.get.postprocess
[2016-02-25 13:16:53] local.INFO: * Script "d7db.table.actions.get.postprocess" output:
object(Object)#695398593 (1) {
["resource"] =>
array(2) {
[0] =>
object(Object)#1771618855 (6) {
["aid"] =>
string(22) "comment_publish_action"
["type"] =>
string(7) "comment"
["callback"] =>
string(22) "comment_publish_action"
["parameters"] =>
string(0) ""
["label"] =>
string(15) "Publish comment"
["extraField"] =>
string(13) "Feed the dog."
}
[1] =>
object(Object)#1858684270 (6) {
["aid"] =>
string(19) "comment_save_action"
["type"] =>
string(7) "comment"
["callback"] =>
string(19) "comment_save_action"
["parameters"] =>
string(0) ""
["label"] =>
string(12) "Save comment"
["extraField"] =>
string(13) "Feed the dog."
}
}
}
[2016-02-25 13:16:53] local.DEBUG: Resource event: d7db.table.{tablename}.get.post_process