i got everything working until this tutorial "Zend Framework greetings to 1.9" but after following this tutorial "Zend Framework 1.9 tutorial 10 modular application part 1"
the fact is that inorder to get modular structure i copied LibraryAcl.php file to modules/default/models folder
I am getting the error Class 'Model_LibraryAcl' not found in /var/www/zftutorial/application/Bootstrap.php
the line corresponding to this in Bootstrap.php is $this->_acl = new Model_LibraryAcl(); so how should this line be changed ?
protected function _initAutoload()
{
$moduleLoader = new Zend_Application_Module_Autoloader(array(
'namespace' => '',
'basePath' => APPLICATION_PATH));
if(Zend_Auth::getInstance()->hasIdentity())
{
Zend_Registry::set('role',Zend_Auth::getInstance()->getStorage()->read()->role);
/*
if Zend_Auth has an instance or an user is actually logged in , access his role
setting a variable which is visible across whole application
*/
}
else
{
Zend_Registry::set('role','guest');
}
$this->_acl = new Model_LibraryAcl();
// $this->_acl = new Default_Model_LibraryAcl();
$this->_auth = Zend_Auth::getInstance();
/*current role will be taken from this variable*/
$fc = Zend_Controller_Front::getInstance();
/*get instance of front controller*/
$fc -> registerPlugin(new Plugin_AccessCheck($this->_acl/*,$this ->_auth*/));
return $moduleLoader;
}
function _initViewHelpers()
{
//layout resource does not come by default in zend framework as of 1.8
$this->bootstrap('layout');
/*initializing the layout resource*/
$layout = $this->getResource('layout');
/*to get the layout object*/
$view = $layout->getView();
/* getting the view of the layout object*/
$view->doctype('XHTML1_STRICT');
$view->headMeta()->appendHttpEquiv('Content-Type', 'text/html;charset=utf-8')
->appendName('description','using view helpers in Zend view') ;
$navContainerConfig = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml','nav') ;
/*class that grabs configuration file and puts it into array format*/
$navContainer = new Zend_Navigation($navContainerConfig);
$view -> navigation($navContainer)->setAcl($this->_acl)->setRole(Zend_Registry::get('role')/*$this->_auth->getStorage()->read()->role*/);
Re:Zend Framework 1.9 tutorials 2 Years, 1 Month ago
Karma: 16
Hello and welcome to my forums
So far i see a problem with your namespace for default module. In order for new Model_LibraryAcl(); to work once it moves into default modules, namespace for default needs to be updated:
$modelLoader = new Zend_Application_Module_Autoloader(array(
'namespace' => '',
'basePath' => APPLICATION_PATH.'/modules/default'));
Lets start troubleshooting from here and see how far this goes.