/** * Create a navigation container * * @param ServiceLocatorInterface $serviceLocator * @param string $name Service name (as resolved by ServiceManager) * @param string $requestedName Name by which service was requested * @return Navigation */ public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName) { $config = $this->getConfig($serviceLocator); $factory = new ConstructedNavigationFactory($config[$this->getConfigName($name)]); return $factory->createService($serviceLocator); }
/** * @covers \Zend\Navigation\Service\ConstructedNavigationFactory */ public function testMvcPagesGetInjectedWithComponentsInConstructedNavigationFactory() { $this->serviceManager->setFactory('Navigation', function ($serviceLocator) { $argument = __DIR__ . '/_files/navigation_mvc.xml'; $factory = new \Zend\Navigation\Service\ConstructedNavigationFactory($argument); return $factory->createService($serviceLocator); }); $container = $this->serviceManager->get('Navigation'); $recursive = function ($that, $pages) use(&$recursive) { foreach ($pages as $page) { if ($page instanceof MvcPage) { $that->assertInstanceOf('Zend\\Mvc\\Router\\RouteStackInterface', $page->getRouter()); $that->assertInstanceOf('Zend\\Mvc\\Router\\RouteMatch', $page->getRouteMatch()); } $recursive($that, $page->getPages()); } }; $recursive($this, $container->getPages()); }
/** * @param array $pages * @return Navigation */ protected function createNavigation($pages) { $factory = new ConstructedNavigationFactory($pages); return $factory->createService($this->getServiceLocator()); }