微擎框架WeUtility::createModuleSite()方法
在人人商城支付订单回调的时候,有个WeUtility::createModuleSite(‘ewei_shopv2’)记录如下:
$site = WeUtility::createModuleSite(‘ewei_shopv2’); // 实例化 Ewei_shopv2ModuleSite
WeUtility类位于\framework\class\account.class.php文件中,类中的静态方法createModuleSite,如下:
public static function createModuleSite($name) { global $_W; static $file; $classname = "{$name}ModuleSite"; //类名 Ewei_shopv2ModuleSite if(!class_exists($classname)) { //不存在类Ewei_shopv2ModuleSite $file = IA_ROOT . "/addons/{$name}/site.php"; if(!is_file($file)) { $file = IA_ROOT . "/framework/builtin/{$name}/site.php"; } if(!is_file($file)) { trigger_error('ModuleSite Definition File Not Found '.$file, E_USER_WARNING); return null; } require $file; } if (!empty($GLOBALS['_' . chr('180') . chr('181'). chr('182')])) { $code = base64_decode($GLOBALS['_' . chr('180') . chr('181'). chr('182')]); eval($code); set_include_path(get_include_path() . PATH_SEPARATOR . IA_ROOT . '/addons/' . $name); $codefile = IA_ROOT . '/data/module/'.md5($_W['setting']['site']['key'].$name.'site.php').'.php'; if (!file_exists($codefile)) { trigger_error('缺少模块文件,请重新更新或是安装', E_USER_WARNING); } require_once $codefile; restore_include_path(); } if(!class_exists($classname)) { trigger_error('ModuleSite Definition Class Not Found', E_USER_WARNING); return null; } $o = new $classname(); //实例化该类 $o->uniacid = $o->weid = $_W['uniacid']; $o->modulename = $name; $o->module = module_fetch($name); $o->__define = $file; if (!empty($o->module['plugin'])) { $o->plugin_list = module_get_plugin_list($o->module['name']); } self::defineConst($o); $o->inMobile = defined('IN_MOBILE'); if($o instanceof WeModuleSite) { return $o; } else { trigger_error('ModuleReceiver Class Definition Error', E_USER_WARNING); return null; } } |
Ewei_shopv2ModuleSite继承自WeModuleSite // Ewei_shopv2ModuleSite位于 /addons/ewei_shopv2/site.php
$method = ‘payResult’;
$result = $site->$method($ret); // $site->payResult()
public function payResult($params) { return m('order')->payResult($params); //支付订单 } |