public function testInitRegistersPluginManager() { $event = new ModuleEvent(); $event->setParam('ServiceManager', $this->serviceLocator); $this->moduleManager->expects(self::any())->method('getEvent')->willReturn($event); $this->serviceLocator->setService('ServiceListener', $this->serviceListener); $this->serviceListener->expects(self::atLeastOnce())->method('addServiceManager'); $actual = $this->sut->init($this->moduleManager); self::assertNull($actual); }
/** * Validate and inject plugin manager options into the service listener. * * @param array $options * @param ServiceListenerInterface $serviceListener * @throws ServiceListenerInterface for invalid $options types */ private function injectServiceListenerOptions($options, ServiceListenerInterface $serviceListener) { if (!is_array($options)) { throw new ServiceNotCreatedException(sprintf('The value of service_listener_options must be an array, %s given.', is_object($options) ? get_class($options) : gettype($options))); } foreach ($options as $key => $newServiceManager) { $this->validatePluginManagerOptions($newServiceManager, $key); $serviceListener->addServiceManager($newServiceManager['service_manager'], $newServiceManager['config_key'], $newServiceManager['interface'], $newServiceManager['method']); } }
/** * @param ServiceListenerInterface $serviceListener * @return ServiceListenerInterface */ public static function registerListenerAggregatesPluginManager(ServiceListenerInterface $serviceListener) { return $serviceListener->addServiceManager('ListenerAggregates', 'listener_aggregates', '\\Abacaphiliac\\Zend\\EventManager\\PluginManager\\ListenerAggregate\\ListenerAggregatesProviderInterface', 'getListenerAggregatesConfig'); }