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访问控制实现原理

你可能感兴趣的:(wecenter学习笔记-Action路由)