public function createService(ServiceLocatorInterface $serviceLocator) { if (!$serviceLocator->has('ServiceListener')) { $serviceLocator->setFactory('ServiceListener', 'Zend\\Mvc\\Service\\ServiceListenerFactory'); } $configuration = $serviceLocator->get('ApplicationConfig'); $listenerOptions = new ListenerOptions($configuration['module_listener_options']); $defaultListeners = new AuthListenerAggregate($listenerOptions); $serviceListener = $serviceLocator->get('ServiceListener'); $serviceListener->addServiceManager($serviceLocator, 'service_manager', 'Zend\\ModuleManager\\Feature\\ServiceProviderInterface', 'getServiceConfig'); $serviceListener->addServiceManager('ControllerLoader', 'controllers', 'Zend\\ModuleManager\\Feature\\ControllerProviderInterface', 'getControllerConfig'); $serviceListener->addServiceManager('ControllerPluginManager', 'controller_plugins', 'Zend\\ModuleManager\\Feature\\ControllerPluginProviderInterface', 'getControllerPluginConfig'); $serviceListener->addServiceManager('ViewHelperManager', 'view_helpers', 'Zend\\ModuleManager\\Feature\\ViewHelperProviderInterface', 'getViewHelperConfig'); $events = $serviceLocator->get('EventManager'); $events->attach($defaultListeners); $events->attach($serviceListener); $moduleEvent = new ModuleEvent(); $moduleEvent->setParam('ServiceManager', $serviceLocator); $moduleManager = new ModuleManager($configuration['modules'], $events); $moduleManager->setEvent($moduleEvent); return $moduleManager; }
public function testCanLoadMultipleModulesWithArgumentGetopt() { $_SERVER['argv'][] = '--cron=url'; $this->defaultListeners->getOptions()->setLazyLoading(array('SomeModule' => array('getopt' => array('cron=s' => 'cron url')))); $configListener = $this->defaultListeners->getConfigListener(); $moduleManager = new ModuleManager(array('SomeModule')); $moduleManager->getEventManager()->attachAggregate($this->defaultListeners); $moduleManager->loadModules(); $loadedModules = $moduleManager->getLoadedModules(); $this->assertEquals(1, count($loadedModules)); }