2013-08-24 48 views
1

我使用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”的命名空间。
我已经添加到了我的bootstrap.php:

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库我有:

  • Controller
    • Helper
    • Plugin

而且在助手我有 “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找不到。错误:

Fatal error: Class 'RoleQuery' not found in /Applications/MAMP/htdocs/GentseFeesten/library/GentseFeesten/Controller/Helper/Acl.php on line 35

我包括我的Acl插件在引导这样的:

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

有谁知道为什么他不能找到我的模型的插件?

回答

0

我必须首先初始化propel插件,然后是acl插件...。刚刚改变了两个功能的位置,它的工作!

相关问题