Zend framework 无法从默认模块调用另一个模块中的模型类?
我的应用程序具有以下结构:Zend framework 无法从默认模块调用另一个模块中的模型类?,zend-framework,class,model,module,Zend Framework,Class,Model,Module,我的应用程序具有以下结构: myapp - applcation - modules - default - controllers - models - Acl.php - views - Bootstrap.php - admin - controllers - models -
myapp
- applcation
- modules
- default
- controllers
- models
- Acl.php
- views
- Bootstrap.php
- admin
- controllers
- models
- ResourceMapper.php
- RoleMapper.php
- views
- Bootstrap.php
- helpers
- layout
- library
- index.php
我想从Acl.php(在默认模块中)调用admin模块中Models文件夹中的类。这是我的代码:
class Model_Acl extends Zend_Acl
{
public $_roleModelMapper;
public $_resourceModelMapper;
function init(){
$this->_roleModelMapper = new Admin_Model_RoleMapper();
$this->_resourceModelMapper = new Admin_Model_ResourceMapper();
}
public function initRole(){
$roles = $this->_roleModelMapper->fetchAll();
foreach ($roles as $role){
$this->addRole($role->getRole());
}
}
public function initResource(){
$resources = $this->_resourceModelMapper->fetchAll();
foreach ($resources as $resource){
if ($resource->getParent()==''){
$this->add(new Zend_Acl_Resource($resource->getResource()));
}else{
$this->add(new Zend_Acl_Resource($resource->getResource()),$resource->getParent());
}
}
}
public function __construct()
{
self::init();
//init role
self::initRole();
//init resource
self::initResource();
//other code here
}
}
但我犯了这样的错误:
Fatal error: Class 'Admin_Model_RoleMapper' not found in C:\xampp\htdocs\test2\application\modules\default\models\Acl.php on line ...
这里是我的应用程序\Bootstrap.php:
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap{
private $_acl = null;
private $_auth = null;
public function _initAutoload()
{
$modelLoader = new Zend_Application_Module_Autoloader(array(
'namespace' => '',
'basePath' => APPLICATION_PATH . "/modules/default",
));
//$this->_acl = new Model_Acl();
$this->_acl = new Model_Acl();
$this->_auth = Zend_Auth::getInstance();
if($this->_auth->hasIdentity()){
Zend_Registry::set('role',$this->_auth->getStorage()->read()->role);
}else{
Zend_Registry::set('role','GUEST');
}
$frontController = Zend_Controller_Front::getInstance();
$frontController->registerPlugin(new Plugin_AccessCheck($this->_acl));
return $modelLoader;
}
}
?>
那么我的代码怎么了?请帮帮我。
注意。查看管理模块引导类的外观(application/modules/admin/bootstrap.php)可能会很有用 它是扩展Zend_应用程序模块引导还是Zend_应用程序引导 它应该扩展Zend_应用程序_模块_引导,否则模块资源加载程序没有使用正确的命名空间初始化
class Admin_Bootstrap extends Zend_Application_Module_Bootstrap {
}
我在每个模块中都有一个引导文件,就像上面的代码一样。我刚刚找到了一种解决问题的方法,在Acl.php文件中创建一个新连接。还有别的办法吗?还有一件事,我把我的项目从Windows7复制到Ubuntu中的/home/myName/public_html文件夹(链接到/opt/lammp/htdocs)。但我遇到以下错误:警告:未知:无法打开流:第0行的未知中的权限被拒绝。据我所知,这可能是许可问题,但我如何解决它??
class Admin_Bootstrap extends Zend_Application_Module_Bootstrap {
}