cmstop传递什么控制器和方法---就实例化该控制器
2016-03-18 17:52
459 查看
object顶级类
class object
第一级抽象类controller
abstract class controller extends object
第二级抽象类controller_abstract 继承controller 祖父类
abstract class controller_abstract extends controller
cmstop.php主程序
设置属性public $app, $controller, $action
用来接收并保存当前请求的模块,控制器,和方法
实例化该对象,
$obj = new $this->class($this);
在cmstop.php中实例化$this.
这次接收到的$this->controller= content
所以.实例化的是content类,调用的方法execute()没有的时候.就到父类中找
$response = $obj->execute();
该execute方法在父类controller_abstract 中
当前所有控制器.都是继承这个父类抽象类controller_abstract 中
在父类中的$this就是类名controller_admin_content
(实例化时的属性$this->controller= content)
父类的$this->app就是实例化时.包含的所有有值的属性
父类的$this->app->action就是所有属性中的action属性
抽象父类的作用:
if ($this->action_exists($this->app->action))//判断该当前类是否存在一个方法 存在就让他运行..call他
用户--方法的--数组
{
$response = call_user_func_array(array($this, $this->app->action), $this->app->args);
}
这样确保.$_GET传递过来什么控制器.cmstop就实例化哪个控制器.
并且调用该对象父类抽象类中方法,$response = $obj->execute();
实例化时.是什么控制器.什么方法.就call他调用该控制器和方法
call_user_func_array(array($this, $this->app->action)
主程序中 定义公用属性
class cmstop extends object
public $app, $controller, $action
接收用户请求的参数
$this->app = 'system';
$this->controller = 'content';
$this->action = 'index';
实例化$this.就是把这些属性作为参数传递给controller_admin_content类.并且触发构造方法.
$obj = new $this->class($this);
再传递给父类的构造方法,
父类检查是否存在请求的方法
if($this->action_exists($this->app->action))
存在就call他
$response = call_user_func_array(array($this, $this->app->action), $this->app->args);
$obj = new $this->class($this);
实例化时.做了2件事.
1实例化该属性中的controller类.
2把属性值作为参数,传递给该类的构造函数,再传递给父类的构造函数
class controller_admin_content extends controller_abstract
function __construct(& $app)
{
parent::__construct($app);
}
class object
第一级抽象类controller
abstract class controller extends object
第二级抽象类controller_abstract 继承controller 祖父类
abstract class controller_abstract extends controller
cmstop.php主程序
设置属性public $app, $controller, $action
用来接收并保存当前请求的模块,控制器,和方法
实例化该对象,
$obj = new $this->class($this);
在cmstop.php中实例化$this.
这次接收到的$this->controller= content
所以.实例化的是content类,调用的方法execute()没有的时候.就到父类中找
$response = $obj->execute();
该execute方法在父类controller_abstract 中
当前所有控制器.都是继承这个父类抽象类controller_abstract 中
在父类中的$this就是类名controller_admin_content
(实例化时的属性$this->controller= content)
父类的$this->app就是实例化时.包含的所有有值的属性
父类的$this->app->action就是所有属性中的action属性
抽象父类的作用:
if ($this->action_exists($this->app->action))//判断该当前类是否存在一个方法 存在就让他运行..call他
用户--方法的--数组
{
$response = call_user_func_array(array($this, $this->app->action), $this->app->args);
}
这样确保.$_GET传递过来什么控制器.cmstop就实例化哪个控制器.
并且调用该对象父类抽象类中方法,$response = $obj->execute();
实例化时.是什么控制器.什么方法.就call他调用该控制器和方法
call_user_func_array(array($this, $this->app->action)
主程序中 定义公用属性
class cmstop extends object
public $app, $controller, $action
接收用户请求的参数
$this->app = 'system';
$this->controller = 'content';
$this->action = 'index';
实例化$this.就是把这些属性作为参数传递给controller_admin_content类.并且触发构造方法.
$obj = new $this->class($this);
再传递给父类的构造方法,
父类检查是否存在请求的方法
if($this->action_exists($this->app->action))
存在就call他
$response = call_user_func_array(array($this, $this->app->action), $this->app->args);
$obj = new $this->class($this);
实例化时.做了2件事.
1实例化该属性中的controller类.
2把属性值作为参数,传递给该类的构造函数,再传递给父类的构造函数
class controller_admin_content extends controller_abstract
function __construct(& $app)
{
parent::__construct($app);
}
相关文章推荐
- docker 创建新的镜像到私有仓库
- docker 创建新的镜像到私有仓库
- Linux命令:tail
- 希尔排序(shell‘ sort)
- java 通过Apache poi导出excel代码demo实例
- Tomcat – Java.Lang.OutOfMemoryError: PermGen Space
- Oralce SQLPlus 以及shell脚本中spool输出到文件时的格式化输出
- Android和Linux动态加载机制
- shell传入参数的处理
- Open vSwitch
- CentOS之更新
- 实战--通过dockerfile本地编译tomcat镜像
- NSURLProtocol和NSRunLoop的那些坑
- CentOS如何挂载硬盘
- linux如何查看磁盘剩余空间
- 【运维监控】ubuntu14 下zabbix服务端安装时缺少依赖解决
- Linux下多线程查看工具(pstree、ps、pstack)
- 配置hadoop开发环境参考链接
- linux重启和关闭系统命令
- APACHE 多站点配置方法