/** * * * @todo Support for object instance error handlers * */ public static function callErrorHandler($Driver, $errmap, $errnum, $errmsg, $user, $requestID, $action, $ident, $extra, &$errerr, $xml, $callback_config) { // $Driver, &$map, $action, $which, $user, $action, $ident, $extra, &$err, $last_action_time, $last_actionident_time, $xml_or_version = '', $qb_identifier_or_locale = array(), $callback_config = array(), $qbxml = null // Build the requestID //$requestID = QuickBooks_Utilities::constructRequestID($action, $ident); $callback = ''; /*if (is_object($this->_instance_onerror) and method_exists($this->_instance_onerror, 'e' . $errnum)) { $func = get_class($this->_instance_onerror) . '->e' . $errnum; }*/ //else if (isset($errmap[$errnum])) { $callback = $errmap[$errnum]; } else { if (isset($errmap[$action])) { $callback = $errmap[$action]; } else { if (isset($errmap['!'])) { $callback = $errmap['!']; } else { if (isset($errmap['*'])) { $callback = $errmap['*']; } } } } // Determine the type of hook $type = QuickBooks_Callbacks::_type($callback, $Driver, null); $vars = array($requestID, $user, $action, $ident, $extra, &$errerr, $xml, $errnum, $errmsg, $callback_config); $errerr = ''; if ($type == QUICKBOOKS_CALLBACKS_TYPE_OBJECT_METHOD) { $Driver->log('Object method error handler: ' . get_class($callback[0]) . '->' . $callback[1], null, QUICKBOOKS_LOG_VERBOSE); $errerr = ''; $continue = QuickBooks_Callbacks::_callObjectMethod($callback, $vars, $errerr, 5); if ($errerr) { $Driver->log('Error handler returned an error: ' . $errerr, null, QUICKBOOKS_LOG_NORMAL); return false; } } else { if ($type == QUICKBOOKS_CALLBACKS_TYPE_FUNCTION) { // It's a callback FUNCTION $Driver->log('Function error handler: ' . $callback, null, QUICKBOOKS_LOG_VERBOSE); $errerr = ''; // This is an error message *returned by* the error handler function $continue = QuickBooks_Callbacks::_callFunction($callback, $vars, $errerr, 5); //$continue = $func($requestID, $user, $action, $ident, $extra, $errerr, $xml, $errnum, $errmsg, $callback_config); if ($errerr) { $Driver->log('Error handler returned an error: ' . $errerr, null, QUICKBOOKS_LOG_NORMAL); return false; } } else { if ($type == QUICKBOOKS_CALLBACKS_TYPE_STATIC_METHOD) { // It's a callback STATIC METHOD //$tmp = explode('::', $func); //$class = trim(current($tmp)); //$method = trim(end($tmp)); $Driver->log('Static method error handler: ' . $callback, null, QUICKBOOKS_LOG_VERBOSE); $errerr = ''; $continue = QuickBooks_Callbacks::_callStaticMethod($callback, $vars, $errerr, 5); if ($errerr) { $Driver->log('Error handler returned an error: ' . $errerr, null, QUICKBOOKS_LOG_NORMAL); return false; } } else { return false; } } } return $continue; }