I use the Propel ORM for my models & mapping. My Models are under /models.
I've added a line to my index.php file to make sure that he finds my models:
// 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(),
)));
I can use the query's in my modules, that works fine. But when I want to use it in my Acl Helper he can't find the models ... .
I've created a namespace in my Zend Framework project called "GentseFeesten".
I've added this to my 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;
}
In my GentseFeesten library I have:
- Controller
- Helper
- Plugin
And in Helper I have "Acl.php". I have a function 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();
}
}
But the RoleQuery can't be found. The error:
Fatal error: Class 'RoleQuery' not found in /Applications/MAMP/htdocs/GentseFeesten/library/GentseFeesten/Controller/Helper/Acl.php on line 35
I've included my Acl Plugin in Bootstrap like this:
new GentseFeesten_Controller_Helper_Acl($this->getResource('frontController'));
$frontController = Zend_Controller_Front::getInstance();
$frontController->registerPlugin(new GentseFeesten_Controller_Plugin_Acl());
Does anyone know why he can't find my models in the plugin?
I had to initialize the propel plugin first and then the acl plugin ... . Just changed the position of the two functions and it worked!