public function __call($method, $args) { //在远程调用配置里面的接口走远程调用 if (isset($this->conf['#all']) || isset($this->conf[$method])) { $conf = isset($this->conf['#all']) ? $this->conf['#all'] : $this->conf[$method]; $rpc = new PI_RPC(); return $rpc->call($method, $args, $this->mod, $this->add, $conf); } else { pi_load_export_file($this->mod, $this->add); if (!is_callable(array($this->instance, $method))) { throw new Exception("proxy.err {$mod} {$add} no method {$method}", 5009); } return pi_call_method($this->instance, $method, $args); } }
function picom($mod, $add = '', $is_server = false) { $mod = strtolower($mod); $add = strtolower($add); //加载一次 static $loaded_mod = array(); if (isset($loaded_mod[$mod . $add])) { return $loaded_mod[$mod . $add]; } //先检测有没有远程配置,如果没有直接加载类,提高效率 $conf_add = $add == '' ? '' : '#' . $add; $conf_name = 'proxy.' . strtolower($mod) . $conf_add; $proxy_conf = Pi::get($conf_name, array()); if ($is_server === false && !empty($proxy_conf)) { //proxy代理类,根据更详细的配置选择哪个接口走远程 $class = new Proxy($mod, $add, $proxy_conf); $loaded_mod[$mod . $add] = $class; } else { //直接加载本地逻辑接口 $loaded_mod[$mod . $add] = pi_load_export_file($mod, $add); } return $loaded_mod[$mod . $add]; }