可以';t在新命名空间中访问模型


Can't acces models in new Namespace

我对我的模型使用Propel ORM;映射。我的模特在模特下面
我在我的index.php文件中添加了一行,以确保他找到我的模型:

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
   realpath(APPLICATION_PATH . '/../library'),
   realpath(APPLICATION_PATH . '/models'),//propel
   get_include_path(),
)));

我可以在我的模块中使用查询,这很好。但当我想在我的Acl Helper中使用它时,他找不到模型。

我在Zend Framework项目中创建了一个名为"GentseFeesten"的命名空间
我已将其添加到我的引导程序中。hp:

protected function _initAutoload() 
{
    $moduleLoader = new Zend_Application_Module_Autoloader(array(
        'namespace' => '',
        'basePath' => APPLICATION_PATH));
    $autoloader = Zend_Loader_Autoloader::getInstance();
    $autoloader->registerNamespace('GentseFeesten_');
    return $moduleLoader;
}

在我的GentseFeesten库中,我有:

  • 控制器
    • 助手
    • 插件

在Helper中,我有"Acl.php"。我有一个函数setRoles():

private function setRoles() {
    // Database query
    $roles = RoleQuery::create()
        ->orderById()
        ->find();
    foreach ($roles as $role) {
        if($parentrole == 0)
        {
            $this->local_acl->addRole(new Zend_Acl_Role($role->getRole()));
        }
        else{
            $this->local_acl->addRole(new Zend_Acl_Role($role->getRole()), $parentrole);
        }
        $parentrole = $role->getRole();
    }
}

但是找不到RoleQuery。错误:

致命错误:在第35行的/Applications/MAMP/htdocs/GentseFeesten/library/GentseFeesten/Controller/Helper/Acl.php中找不到类"RoleQuery"

我在引导程序中包含了我的Acl插件,如下所示:

new GentseFeesten_Controller_Helper_Acl($this->getResource('frontController'));
    $frontController = Zend_Controller_Front::getInstance();
    $frontController->registerPlugin(new GentseFeesten_Controller_Plugin_Acl());

有人知道他为什么在插件中找不到我的模型吗?

我必须先初始化推进插件,然后初始化acl插件。只是改变了两个功能的位置,它就起作用了!