zend-framework2zend-navigation

Zend Navigation, ACL and Partials


I have Zend Navigation object with Acl and Roles:

echo $this->navigation()->menu('navigation')
->setAcl($this->acl)
->setRole(($this->user ? 'user' : 'guest'))
->render();

and its work perfectly (hides some pages)

BUT

when i use custom partial:

echo $this->navigation()->menu('navigation')
->setAcl($this->acl)
->setRole(($this->user ? 'user' : 'guest'))
->setPartial('partial/twitterBootstrapNavHeadUl.phtml')
->render();

and this partial content

foreach ($this->container as $page)
    echo $this->navigation()->menu()->htmlify($page);

it pass to the partial $this->container with ALL pages (via acl setted as unaviable)

Maybe i should pass acl etc to partial

foreach ($this->container as $page)
    echo $this->navigation()->menu()->setAcl($this->acl)->setRole(($this->user ? 'user' : 'guest'))->htmlify($page); // ?????????????????????

but how to achieve it?

Is there something what I should do/know?


Solution

  • foreach ($this->container as $page){
        if($this->navigation()->accept($page))
            echo $this->navigation()->menu()->htmlify($page);
    }
    

    Why? In a custom view you have to run the check on your own.