I have been writing some code to extend VersionX to make a draft, submit, approve, publish system. This currently is not related to Gallery but I have a plugin that is called on the OnBeforeDocFormSave event and runs this code below. When calling resource->getTVValue() Gallery throws an error output but nothing in the logs.
Error Response:
{"success":false,"message":"\/core\/components\/gallery\/elements\/tv\/output\/\n","total":0,"data":[],"object":[]}
Plugin code where error is happening:
if (method_exists($resource,'getTemplateVars')) {
$tvs = $resource->getTemplateVars();
} else {
$tvs = call_user_func(array($this,'getTemplateVars'),$resource);
}
$tvArray = array();
/* @var modTemplateVar $tv */
foreach ($tvs as $tv) {
$tmp = $tv->get(array('id','value'));
// get the raw post value for a draft -
if ( $post_values && isset($_POST['tv'.$tmp['id']]) ) {
// this is the processed value
$processed_value = '';
$processed_value = $resource->getTVValue($tmp['id']);
/**
* @TODO Fix the Gallery Extras is causing an error when calling on $resource->getTVValue() Here, why? And nothing in the error log
* Repsonse:
* {"success":false,"message":"\/core\/components\/gallery\/elements\/tv\/output\/\n","total":0,"data":[],"object":[]}
* Uninstall Gallery and works great?
*/
if ( $processed_value != $_POST['tv'.$tmp['id']] ) {
$tmp['value'] = $_POST['tv'.$tmp['id']];
}
}
$tvArray[] = $tmp;//$tv->get(array('id','value'));
}
$version->set('tvs',$tvArray);
You can see the
complete file on github.
- Am I doing something wrong or better way to do this?
- Is Gallery Plugin not functioning properly?
Any help would be great!
Thanks for reviewing.