mMerchants = []; } public function add($mch_name,$parmas) { $bridge = $this->find($mch_name); if(is_null($bridge)) { return false; } $ret = $bridge->add($parmas); return $ret; } public function notify($mch_name,$parmas) { $bridge = $this->find($mch_name); if(is_null($bridge)) { return false; } $ret = $bridge->notify($parmas); if($ret) { return "SUCCESS"; } else { return "ERROR"; } } private function find($name) { try { if(array_key_exists($name,$this->mMerchants)) { return $this->mMerchants[$name]; } $class = "rbridge\\{$name}\\Bridge"; if(class_exists($class,false)) { $merchant = new $class(); $this->mMerchants[$name] = $merchant; return $merchant; } else { $error = "Error: class {$class} isn't exists!"; throw new Exception($error); } } catch (Exception $ex) { Log::record($ex->getMessage(),Log::ERR); } return null; } }