Bonjour,
J'ai un petit soucis avec le Zend_Acl. Je suppose qu'il faut le stocker en session pour pouvoir tester les droits à chaque action, mais je n'y arrive pas. J'essaye en fait d'enregistrer l'Acl dans Zend_Registry, mais il refuse de l'enregistrer : quand je change de controller, il "oubli" mon index Acl...
Voilà, en gros, le code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 //dans Auth_Controller $data = $authAdapter->getResultRowObject(null,'g_u_pass'); Zend_Loader::loadClass('Models_MyAcl'); $oAcl=new Models_MyAcl(Zend_Registry::get('dbAdapter'), $data->g_u_id); Zend_Registry::set('acl', $oAcl);//Si je fait ici un print_r(Zend_Registry::get('acl')), c'est OK je vois l'Acl $this->_redirect('/general');J'ai l'erreur suivante à la ligne du "if" :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 //Dans General_Controller if(Zend_Registry::get('acl')->isAllowed('curentUserRole','general_index_action')){ echo 'OK!'; }else{ echo 'NOK!'; }
Code : Sélectionner tout - Visualiser dans une fenêtre à part Fatal error: Uncaught exception 'Zend_Exception' with message 'No entry is registered for key 'acl'' in C:\wamp\php\includes\Zend\Registry.php:145 Stack trace: #0 C:\wamp\www\intralltub_general\default\ctrl\GeneralController.php(33): Zend_Registry::get('acl') #1 C:\wamp\php\includes\Zend\Controller\Action.php(497): GeneralController->indexAction() #2 C:\wamp\php\includes\Zend\Controller\Dispatcher\Standard.php(230): Zend_Controller_Action->dispatch('indexAction') #3 C:\wamp\php\includes\Zend\Controller\Front.php(889): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #4 C:\wamp\www\intralltub_general\index.php(96): Zend_Controller_Front->dispatch() #5 {main} thrown in C:\wamp\php\includes\Zend\Registry.php on line 145
Partager