Skip to content

Instantly share code, notes, and snippets.

@macnibblet
Created August 2, 2012 08:43
Show Gist options
  • Save macnibblet/3235505 to your computer and use it in GitHub Desktop.
Save macnibblet/3235505 to your computer and use it in GitHub Desktop.
/**
* Expected to return \Zend\ServiceManager\Config object or array to
* seed such an object.
*
* @return array|\Zend\ServiceManager\Config
*/
public function getViewHelperConfig()
{
return array(
'initializers' => array(
function($instance, $viewServiceManager) {
if ($instance instanceof ServiceLocatorAwareInterface) {
$instance->setServiceLocator($viewServiceManager->getServiceLocator());
}
}
),
'factories' => array(
'navigation' => function($sm) {
$navigation = $sm->get('Zend\View\Helper\Navigation');
$navigation->setAcl($sm->getServiceLocator()->get('acl'));
$navigation->setRole($sm->getServiceLocator()->get('user_service_auth')->getIdentity()->getRole());
return $navigation;
}
)
);
}
@messyOne
Copy link

Why you have added an initializers?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment