I'm using migxdb with child resources. When I publish, unpublish or edit a child resource using the migxdb tv row action buttons, I would like to invoke the OnDocFormSave event. (there's a plugin that executes on this event).
I think I've got the pieces of the puzzle, but I just can't put them together.
1. I think I need to create a new update.php file, put it in a new folder and put that folder name in the MIGXdb configuration for 'processorspath'
2. In the new update.php I have to put something like this to invoke the event:
$modx->invokeEvent("OnDocFormSave", array (
"mode" => "upd",
"id" => $key
));
But.. how do I transfer the ID of the child resource to this function? And is 'mode' necessary or can I leave it out?
And how can I make it invoke the event on both edit, and publish/unpublish?
Second, where should I put it exactly in the update.php file? This is the contents of the 'normal' update.php:
<?php
$task=$modx->migx->getTask();
$filename = basename(__file__);
$processorspath = dirname(dirname(__file__)). '/' ;
$updateerror=false;
$filenames = array();
if ($processor_file = $modx->migx->findProcessor($processorspath,$filename,$filenames)){
include_once ($processor_file);
}
if ($updateerror){
return $modx->error->failure($errormsg);
}
return $modx->error->success('',$object);
?>
Another idea is to copy the plugin code to a snippet and just call that snippet instead of invoking the event. What would you consider the best option?
Thanks for any help!