1 / 4
文档名称:

opencart源码分析.doc

格式:doc   大小:21KB   页数:4页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

opencart源码分析.doc

上传人:mh900965 2018/6/24 文件大小:21 KB

下载得到文件列表

opencart源码分析.doc

相关文档

文档介绍

文档介绍://
该文件的主要作用就是分析该动作的一些信息
比如:文件的目录、要调用的类、要调用类中的方法名、提取参数
$action = new Action('common/home')
根据'common/home' 进行推断出调用的类,文件目录等一些信息;
---------------------------------------------------------------------------------------------------------------

该类是调度的中心;一切的调度都由这个类开始;
$controller->dispatch($action, new Action('error/not_found'));
根据初始化的$action,进行开始
public function dispatch($action, $error) {
$this->error = $error;

foreach ($this->pre_action as $pre_action) {
$result = $this->execute($pre_action);//执行一些预先处理的动作
if ($result) {
$action = $result;
break;
}
}

while ($action) {
$action = $this->execute($action); //开始调用动作的目的
}
}

private function execute($action) {
$file = $action->getFile();
$class = $action->getClass();
$method = $action->getMethod();
$args = $action->getArgs();
$action = '';
if (file_exists($file)) {
require_once($file);
$controller = new $class($this->registry);

if (is_callable(array($controller, $method))) {
$action = call_user_func_array(array($controller, $method), $args);//调用控制器
} else {
$action = $this->error;

$this->error = '';
}
} else {
$action = $this->error;

$this->error = '';
}

return $action;
}
---------------------------------------------------------------------------------------------------------------

这是个抽象类,所有的控制器都继承该类
cont