モデルとマッピングには Propel ORM を使用しています。私のモデルは /models の下にあります。
彼が私のモデルを見つけられるように、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 ヘルパーで使用したい場合、彼はモデルを見つけることができません ... .
「GentseFeesten」という Zend Framework プロジェクトに名前空間を作成しました。
これを 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ライブラリには次のものがあります:
- コントローラ
- ヘルパー
- プラグイン
そしてヘルパーには「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 プラグインを Bootstrap に含めました。
new GentseFeesten_Controller_Helper_Acl($this->getResource('frontController'));
$frontController = Zend_Controller_Front::getInstance();
$frontController->registerPlugin(new GentseFeesten_Controller_Plugin_Acl());
プラグインで私のモデルが見つからない理由を知っている人はいますか?