**/ class twIf_RPC_Helper_Dispatch { private $Parent = null; // {{{ __construct /** * Create a new Call-Dispatcher * * @param object $Parent Our parent twIf_RPC-Handle * * @access friendly * @return void **/ function __construct ($Parent) { $this->Parent = $Parent; } // }}} // {{{ __call /** * Catch unbound calls to this call * * @param string $Name Name of the called function * @param array $Parameters Parameters for function-call * * @access public * @return mixed **/ public function __call ($Name, $Parameters) { // Just make sure that we have a parent assigned if (!is_object ($this->Parent)) { trigger_error (twIf_i18n::getText ('No parent-handle assigned')); return false; } // Retrive all defined RPC-Functions if (!is_array ($Functions = $this->Parent->getFunctions ())) return $this->Parent->raiseError (twIf_RPC::ERROR_UNKNOWN_FUNCTION, 'Could not retrive defined functions'); // Check if we have such function registered $Name = strtolower ($Name); if (!isset ($Functions [$Name]) || !is_object ($Functions [$Name])) return $this->Parent->raiseError (twIf_RPC::ERROR_UNKNOWN_FUNCTION, 'Unknown Function: ' . $Name); $Function = $Functions [$Name]; // Check signature of function if (!$Function->checkParameters ($Parameters)) return $this->Parent->raiseError (twIf_RPC::ERROR_INVALID_PARAMETERS, 'Function-Signature does not match'); // Call the function return $Function->runCallback ($Parameters); } // }}} } ?>