ThinkPHP 面向切面编程之行为Behavior分析
面向切面是一种设置模式
把一个大块的功能给分解为小块的功能
这样小块的功能利于开发、维护、升级、部署
tp框架的面向切面编程设计体现在Behavior行为里边
行为:
tp框架的行为Behavior如何执行:
- 框架执行流程分析:index.php ThinkPHP.php Think.class.php App.class.php
- Think::start();
- ThinkPHP/Conf/Mode/common.phptags标签内容是行为的内容
- 自定义shop/Common/conf/tags.php文件
- 自定义tags.php内容会覆盖指定的common.php的配置内容
App.class.php
- function run();
- Hook::listen(‘app_begin’);
- ThinkPHP/Library/Think/Hook.class.php
- function listen()
- tags标签的内容解析出来: CheckLang
- self::exec(‘CheckLang’);
- function exec()
- CheckLangBehavior
- new CheckBehavior;
- obj -> run(); 运行具体行为