WeUtility::createModule($name)的详细分析
为什么想写这篇文章呢?
因为这个函数module_build_form引起的
~~~
function module_build_form($name, $rid) {
$rid = intval($rid);
$m = WeUtility::createModule($name); //初始化模块
return $m->fieldsFormDisplay($rid); //获取对应的模块代码
}
~~~
WeUtility是在 framework\class\account.class.php中实现
~~~
class WeUtility {
//创建模块类
public static function createModule($name) {
global $_W;
static $file;
$classname = ucfirst($name) . 'Module';
if(!class_exists($classname)) {
$file = IA_ROOT . "/addons/{$name}/module.php";
if(!is_file($file)) {
$file = IA_ROOT . "/framework/builtin/{$name}/module.php"; //模块在类里
}
}
}
}
~~~
发现其实是在 "/framework/builtin/" 里
树形结构如下:
![](https://box.kancloud.cn/2016-05-24_57444bc57522f.jpg)