I want Navigation to show only items allowed by Acl, but I have problems linking Navigation with Acl - when I do it, like it is shown in the official example or some other resources on the internet, my navigation still shows all the items like without Acl.
In the Bootstrap, I am doing :
$view->navigation()->setContainer($container);
$view->navigation()->setAcl($acl)->setRole("1");
Where :
- $view is Zend_View object
- $container is Zend_Navigation object
- $acl is Zend_Acl object
I have the initial navigation array set up as it should, acl and navigation objects also seem fine and contain what they should contain, so I am not going to post them here.
At the moment we got it working using constructions like :
if(!$acl->isAllowed(/* auth data, controller, action */)) {
unset(/* this page from pages array */);
}
but this is not pretty at all and not like a one-liner in the official example.
My question is what is most likely my problem here and what are most usual problems and mistakes that developers make while combining Zend_Navigation with Zend_Acl?
Maybe I can find a solution among those and this could help other developers who are having problems with this issue.