QuickBooks/Callbacks.php
static public function callHook($Driver, &$hooks, $hook, $requestID, $user, $ticket, &$err, $hook_data, $callback_config = array())
	{
		// There's a bug somewhere that passes a null value to this function... ?
		if (!is_array($hooks))
		{
			$hooks = array();
		}

		// First, clean up the hooks array
		foreach ($hooks as $key => $value)
		{
			if (!is_array($value))
			{
				$hooks[$key] = array( $value );
			}
		}

		// Clean up the hook data
		foreach (array( 'requestID' => $requestID, 'user' => $user, 'ticket' => $ticket ) as $key => $value)
		{
			if (empty($hook_data[$key]))
			{
				$hook_data[$key] = $value;
			}
		}

		// Check if the hook is set, if so, call it!
		if (isset($hooks[$hook]))
		{
			// Drop a message in the log
			if ($Driver)
			{
				$Driver->log('Calling hooks for: ' . $hook, $ticket, QUICKBOOKS_LOG_VERBOSE);
			}

			// Loop through the hooks
			foreach ($hooks[$hook] as $callback)
			{
				// Determine the type of hook
				$type = QuickBooks_Callbacks::_type($callback, $Driver, $ticket);

				if ($Driver)
				{
					// Log the callback for debugging
					$Driver->log('Calling callback [' . $type . ']: ' . gettype($callback), $ticket, QUICKBOOKS_LOG_DEVELOP);
				}

				$vars = array( $requestID, $user, $hook, &$err, $hook_data, $callback_config );
				if ($type == QUICKBOOKS_CALLBACKS_TYPE_OBJECT_METHOD)			// Object instance method hook
				{
					$object = $callback[0];
					$method = $callback[1];

					if ($Driver)
					{
						$Driver->log('Calling hook instance method: ' . get_class($callback[0]) . '->' . $callback[1], $ticket, QUICKBOOKS_LOG_VERBOSE);
					}

					$ret = QuickBooks_Callbacks::_callObjectMethod( array( $object, $method ), $vars, $err);
					//$ret = call_user_func_array( array( $object, $method ), array( $requestID, $user, $hook, &$err, $hook_data, $callback_config) );
				}
				else if ($type == QUICKBOOKS_CALLBACKS_TYPE_FUNCTION)		// Function hook
				{
					if ($Driver)
					{
						$Driver->log('Calling hook function: ' . $callback, $ticket, QUICKBOOKS_LOG_VERBOSE);
					}

					$ret = QuickBooks_Callbacks::_callFunction($callback, $vars, $err);
					//$ret = $callback($requestID, $user, $hook, $err, $hook_data, $callback_config);
					// 			$requestID, $user, $action, $ident, $extra, $err, $xml, $qb_identifier
				}
				else if ($type == QUICKBOOKS_CALLBACKS_TYPE_STATIC_METHOD)		// Static method hook
				{
					if ($Driver)
					{
						$Driver->log('Calling hook static method: ' . $callback, $ticket, QUICKBOOKS_LOG_VERBOSE);
					}

					//$tmp = explode('::', $callback);
					//$class = trim(current($tmp));
					//$method = trim(end($tmp));

					$ret = QuickBooks_Callbacks::_callStaticMethod($callback, $vars, $err);
					//$ret = call_user_func_array( array( $class, $method ), array( $requestID, $user, $hook, &$err, $hook_data, $callback_config) );
				}
				else if ($type == QUICKBOOKS_CALLBACKS_TYPE_HOOK_INSTANCE)
				{
					// Just call the ->hook() method

					if ($Driver)
					{
						$Driver->log('Calling hook instance: ' . get_class($callback), $ticket, QUICKBOOKS_LOG_VERBOSE);
					}

					$ret = QuickBooks_Callbacks::_callObjectMethod( array( $callback, 'hook' ), $vars, $err);
				}
				else
				{
					return false;
				}

				// If the hook returns FALSE, then *do not* run all of the other hooks, just return FALSE here
				if ($ret == false)
				{
					return false;
				}
			}
		}

		return true;
	}
static public function callHook($Driver, &$hooks, $hook, $requestID, $user, $ticket, &$err, $hook_data, $callback_config = array())
	{
		// There's a bug somewhere that passes a null value to this function... ?
		if (!is_array($hooks))
		{
			$hooks = array();
		}

		// First, clean up the hooks array
		foreach ($hooks as $key => $value)
		{
			if (!is_array($value))
			{
				$hooks[$key] = array( $value );
			}
		}

		// Clean up the hook data
		foreach (array( 'requestID' => $requestID, 'user' => $user, 'ticket' => $ticket ) as $key => $value)
		{
			if (empty($hook_data[$key]))
			{
				$hook_data[$key] = $value;
			}
		}

		// Check if the hook is set, if so, call it!
		if (isset($hooks[$hook]))
		{
			// Drop a message in the log
			if ($Driver)
			{
				$Driver->log('Calling hooks for: ' . $hook, $ticket, QUICKBOOKS_LOG_VERBOSE);
			}

			// Loop through the hooks
			foreach ($hooks[$hook] as $callback)
			{
				// Determine the type of hook
				$type = QuickBooks_Callbacks::_type($callback, $Driver, $ticket);

				if ($Driver)
				{
					// Log the callback for debugging
					$Driver->log('Calling callback [' . $type . ']: ' . gettype($callback), $ticket, QUICKBOOKS_LOG_DEVELOP);
				}

				$vars = array( $requestID, $user, $hook, &$err, $hook_data, $callback_config );
				if ($type == QUICKBOOKS_CALLBACKS_TYPE_OBJECT_METHOD)			// Object instance method hook
				{
					$object = $callback[0];
					$method = $callback[1];

					if ($Driver)
					{
						$Driver->log('Calling hook instance method: ' . get_class($callback[0]) . '->' . $callback[1], $ticket, QUICKBOOKS_LOG_VERBOSE);
					}

					$ret = QuickBooks_Callbacks::_callObjectMethod( array( $object, $method ), $vars, $err);
					//$ret = call_user_func_array( array( $object, $method ), array( $requestID, $user, $hook, &$err, $hook_data, $callback_config) );
				}
				else if ($type == QUICKBOOKS_CALLBACKS_TYPE_FUNCTION)		// Function hook
				{
					if ($Driver)
					{
						$Driver->log('Calling hook function: ' . $callback, $ticket, QUICKBOOKS_LOG_VERBOSE);
					}

					$ret = QuickBooks_Callbacks::_callFunction($callback, $vars, $err);
					//$ret = $callback($requestID, $user, $hook, $err, $hook_data, $callback_config);
					// 			$requestID, $user, $action, $ident, $extra, $err, $xml, $qb_identifier
				}
				else if ($type == QUICKBOOKS_CALLBACKS_TYPE_STATIC_METHOD)		// Static method hook
				{
					if ($Driver)
					{
						$Driver->log('Calling hook static method: ' . $callback, $ticket, QUICKBOOKS_LOG_VERBOSE);
					}

					//$tmp = explode('::', $callback);
					//$class = trim(current($tmp));
					//$method = trim(end($tmp));

					$ret = QuickBooks_Callbacks::_callStaticMethod($callback, $vars, $err);
					//$ret = call_user_func_array( array( $class, $method ), array( $requestID, $user, $hook, &$err, $hook_data, $callback_config) );
				}
				else if ($type == QUICKBOOKS_CALLBACKS_TYPE_HOOK_INSTANCE)
				{
					// Just call the ->hook() method

					if ($Driver)
					{
						$Driver->log('Calling hook instance: ' . get_class($callback), $ticket, QUICKBOOKS_LOG_VERBOSE);
					}

					$ret = QuickBooks_Callbacks::_callObjectMethod( array( $callback, 'hook' ), $vars, $err);
				}
				else
				{
					return false;
				}

				// If the hook returns FALSE, then *do not* run all of the other hooks, just return FALSE here
				if ($ret == false)
				{
					return false;
				}
			}
		}

		return true;
	}
Call a hook function / object method / static method

@param QuickBooks_Driver $Driver		QuickBooks_Driver instance for logging
@param array $hooks					An array of arrays of hooks
@param string $hook					The hook to call
@param string $requestID				The requestID of the request which caused this hook to be called
@param string $user					The username of the QuickBooks user
@param string $ticket				The ticket for the session
@param string $err					Any errors that occur will be passed back here
@param array $hook_data				An array of additional data to be passed to the hook
@param array $callback_config		An array of additional callback data
@return boolean