Zend Navigation Helper not communicating with ZfcRbac

290 Views Asked by At

I have a problem implemented the ZfcRbac. At the moment the Rbac works and i enter a page on a certain url i will receive a 403. The code i used for this is the following:

'zfc_rbac'                   => array(
    'guards'         => array(
        'ZfcRbac\Guard\RouteGuard' => array(
            'relation*' => array('relation'),
        ),
    ),
    'role_provider'  => array(
        'ZfcRbac\Role\InMemoryRoleProvider' => array(
            'relation' => array(
                'permissions' => array('view', 'edit', 'delete'),
            ),
        ),
    ),
),

The problem occurs when i try to let it talk with the Zend Navigation helper. Due some odd reason the navigation keeps telling me it can access the page. When i click it it seems you can't. Here is some code to check it

public function onBootstrap(MvcEvent $e)
{
    $application        = $e->getApplication();
    $serviceManager     = $application->getServiceManager();
    $sharedEvents = $application->getEventManager()->getSharedManager();
    $authorization = $serviceManager->get('ZfcRbac\Service\AuthorizationService');

    $sharedEvents->attach(
            'Zend\View\Helper\Navigation\AbstractHelper', 'isAllowed', function (EventInterface $e) use ($authorization)
    {
        $page = $e->getParam('page');
        $permission = $page->getPermission();
        return $authorization->isGranted($permission);
    }
    );
}

And the view helper will be called like:

<?=$this->navigation('navigation')->menu()->setPartial(array('sidebar.phtml', 'css'=>'nav navbar-nav'))->render();?>

Hope someone knows the answer on this one.

Thanks in advance.

0

There are 0 best solutions below