2011-06-08 91 views
2

我遇到一个名为'auth'(包含tank_auth认证库)的模块的配置文件的路径问题。HMVC Codeigniter中配置文件的路径(HMVC + Tank Auth)

的“身份验证”模块中的每个函数加载,加载在application/modules/auth/config/tank_auth.php的tank_auth配置文件中的“tank_auth.php”库:

function __construct() 
{ 
    $this->ci =& get_instance(); 

    $this->ci->load->config('tank_auth', TRUE); //<--- HERE IT IS!! 

    $this->ci->load->library('session'); 
    $this->ci->load->database(); 
    $this->ci->load->model('tank_auth/users'); 

    // Try to autologin 
    $this->autologin(); 
} 

在另一个模块,我插入下面的函数的调用在鉴于 '身份验证' 模块中:

<?php modules::run('auth/cp'); ?> 

这让我错误

An Error Was Encountered 
The configuration file tank_auth.php does not exist. 

我通过在Tank_auth.php中的__construct函数中更改内容来解决此问题,即从'tank_auth'到'auth/tank_auth'的路径。

function __construct() 
{ 
    $this->ci =& get_instance(); 

    $this->ci->load->config('auth/tank_auth', TRUE); // <--- ADDED module name 

    $this->ci->load->library('session'); 
    $this->ci->load->database(); 
    $this->ci->load->model('tank_auth/users'); 

    // Try to autologin 
    $this->autologin(); 
} 

我的问题是,为什么犯规正从另一模块调用的权威性功能CP看到“权威性”模块中的配置文件?不能在模块的名称中添加config('tank_auth', TRUE)吗?

回答

1

这就是HMVC模块的设计方式。

$this->ci->load->config('tank_auth', TRUE); 

这只会在默认的配置文件夹中搜索。请参阅official CI HMVC页面的“功能”部分,在控制器的上下文中提及它。