wecenter学习笔记-Action路由

该文是wecenter学习笔记的一部分

Action路由

** 创建controller **

system/aws_app.inc.php

public static function create_controller($controller, $app_dir)
    {
        if ($app_dir == '' OR trim($controller, '/') === '')
        {
            return false;
        }

        $class_file = $app_dir . $controller . '.php';

        $controller_class = str_replace('/', '_', $controller);

        if (! file_exists($class_file))
        {
            return false;
        }

        if (! class_exists($controller_class, false))
        {
            require_once $class_file;
        }

        // 解析路由查询参数
        load_class('core_uri')->parse_args();

        if (class_exists($controller_class, false))
        {
            return new $controller_class();
        }

        return false;
    }

** 执行action method **

system/aws_app.inc.php#run

$action_method = load_class('core_uri')->action . '_action';

// 判断
if (! is_object($handle_controller) OR ! method_exists($handle_controller, $action_method))
{
    HTTP::error_404();
}

...

// 执行
if (!$_GET['id'] AND method_exists($handle_controller, load_class('core_uri')->action . '_square_action'))
{
    $action_method = load_class('core_uri')->action . '_square_action';
}

$handle_controller->$action_method();

Zend Session 框架←o→Controller访问控制实现原理

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,477评论 19 139
  • 该文是wecenter学习笔记的一部分 Zend Session 框架 PHP runtime对Session的支...
    imhaiyang阅读 5,145评论 0 0
  • 1. Java基础部分 基础部分的顺序:基本语法,类相关的语法,内部类的语法,继承相关的语法,异常的语法,线程的语...
    子非鱼_t_阅读 31,955评论 18 399
  • 入了腊月,天有些凉,便将火盆生了火取暖。我独自一人在屋檐下饮酒,仅仅三杯,竟有些醉人,可道是酒不醉人人自醉。想起从...
    _阿阿阿阿琳阅读 2,828评论 0 1
  • 什么是光纤跳线? 光纤跳线,指两端带有连接头的光纤线缆,其作用是可以直接快速地连接到计算机或其他网络设备。光纤跳线...
    enrilink阅读 5,117评论 0 0