public function __invoke(Event $e) { $router = $e->getRouter(); Page::setDefaultRouter($router); if (null === $this->cache || null === ($navigation = $this->cache->getItem(self::CACHE_KEY))) { $collection = $e->getTarget()->getPageCollection(); $navigation = $this->parser->parse($collection); if (null !== $this->cache) { $this->cache->setItem(self::CACHE_KEY, $navigation); } } $this->helper->setContainer($navigation); }
public function onBootstrap(MvcEvent $e) { $sm = $e->getApplication()->getServiceManager(); /* @var $eventManager \Zend\EventManager\EventManager */ $eventManager = $e->getApplication()->getEventManager(); $eventManager->attach($sm->get('Authorize\\Guard\\Controller')); $eventManager->attach($sm->get('Authorize\\View\\UnauthorizedStrategy')); /* @var $acl \Authorize\Permission\Acl */ $acl = $sm->get('Authorize\\Permission\\Acl'); /* @var $serviceUser \User\Service\User */ $serviceUser = $sm->get('User\\Service\\User'); \Zend\View\Helper\Navigation::setDefaultAcl($acl); \Zend\Navigation\Page\Mvc::setDefaultRouter($sm->get('router')); }
/** * OnBootstrap listener * @param $e */ public function onBootstrap(\Zend\Mvc\MvcEvent $e) { $application = $e->getApplication(); $sm = $application->getServiceManager(); $viewHelperPluginManager = $sm->get('view_helper_manager'); /* @var $viewHelperPluginManager \Zend\View\HelperPluginManager */ //Register DluTwBootstrap view helpers $viewHelperConfigurator = $sm->get('dlu_twb_view_helper_configurator'); /* @var $viewHelperConfigurator \DluTwBootstrap\Form\View\HelperConfig */ $viewHelperConfigurator->configureServiceManager($viewHelperPluginManager); //Register DluTwBootstrap view navigation helpers $navViewHelperConfigurator = $sm->get('dlu_twb_nav_view_helper_configurator'); /* @var $navViewHelperConfigurator \DluTwBootstrap\View\Helper\Navigation\PluginConfigurator */ $navHelperPluginManager = $viewHelperPluginManager->get('navigation')->getPluginManager(); $navViewHelperConfigurator->configureServiceManager($navHelperPluginManager); //Prepare the \Zend\Navigation\Page\Mvc for use //The pages in navigation container created with a factory have the router injected, //but any other explicitly created page needs the router too, so it makes sense to set the default router $router = $sm->get('router'); \Zend\Navigation\Page\Mvc::setDefaultRouter($router); }
public function testNoExceptionForGetHrefIfDefaultRouterIsSet() { $page = new Page\Mvc(array( 'label' => 'foo', 'action' => 'index', 'controller' => 'index', 'route' => 'default', 'defaultRouter' => $this->router )); // If the default router is not used an exception will be thrown. // This method intentionally has no assertion. $page->getHref(); $page->setDefaultRouter(null); }