QeePHP controller.php文件内容

<?php


class QReflection_Controller
{
    /**
     * 控制器名称
     *
     * @var string
     */
    protected $_controller_name;


    /**
     * 控制器名字空间
     *
     * @var string
     */
    protected $_namespace;


    /**
     * 控制器的 UDI
     *
     * @var string
     */
    protected $_udi;


    /**
     * 控制器的类名称
     *
     * @var string
     */
    protected $_controller_class_name;


    /**
     * 控制器文件完整路径
     *
     * @var string
     */
    protected $_controller_file_path;


    /**
     * 控制器所属模块的反射
     *
     * @var QReflection_Module
     */
    protected $_module;


    /**
     * 构造函数
     *
     * @param QReflection_Module $module
     * @param string $controller_name
     * @param string $namespace
     */
    function __construct(QReflection_Module $module, $controller_name, $namespace = null)
    {
        $names = explode('::', $controller_name);
        if (isset($names[1]))
        {
            $namespace = $names[0];
            $controller_name = $names[1];
        }


        $this->_module = $module;
        $this->_controller_name = $controller_name;
        $this->_namespace = $namespace;


        // 确定控制器对应的文件
        $controller_name = strtolower($controller_name);
        $dir = rtrim($module->moduleDir(), '/\\') . '/controller';
        if ($namespace)
        {
            $this->_controller_file_path = "{$dir}/{$namespace}/{$controller_name}_controller.php";
        }
        else
        {
            $this->_controller_file_path = "{$dir}/{$controller_name}_controller.php";
        }


        // 确定控制器的类名称
        if (!$module->isDefaultModule())
        {
            $class = ucfirst($module->moduleName()) . '_';
        }
        else
        {
            $class = '';
        }
        $class .= 'Controller_';
        if ($namespace) $class .= ucfirst($namespace) . '_';
        $class .= ucfirst($controller_name);
        $this->_controller_class_name = $class;


        // 确定控制器的 UDI
        if ($namespace)
        {
            $udi = $namespace . '::' . $controller_name;
        }
        else
        {
            $udi = $controller_name;
        }


        if (!$module->isDefaultModule())
        {
            $udi .= '@' . $module->moduleName();
        }
        $this->_udi = $udi;
    }


    /**
     * 返回该控制器所属模块的反射
     *
     * @return QReflection_Module
     */
    function module()
    {
        return $this->_module;
    }


    /**
     * 返回该控制器所属应用的反射
     *
     * @return QReflection_Application
     */
    function app()
    {
        return $this->_module->app();
    }


    /**
     * 返回控制器名称
     *
     * @return string
     */
    function controllerName()
    {
        return $this->_controller_name;
    }


    /**
     * 返回控制器文件的完整路径
     *
     * @return string
     */
    function filePath()
    {
        return $this->_controller_file_path;
    }


    /**
     * 返回控制器所属的名字空间
     *
     * @return string
     */
    function namespace()
    {
        return $this->_namespace;
    }


    /**
     * 返回控制器所述模块的名字
     *
     * @return string
     */
    function moduleName()
    {
        return $this->module()->moduleName();
    }


    /**
     * 返回控制器的类名称
     *
     * @return string
     */
    function className()
    {
        return $this->_controller_class_name;
    }


    /**
     * 返回控制器的 UDI 名称
     *
     * @return string
     */
    function UDI()
    {
        return $this->_udi;
    }
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值