defaultValueProvider = $defaultValueProvider; $this->objectManagerConfig = $objectManagerConfig; $this->reflectionGenerator = $reflectionGenerator; $this->serviceMethodsMap = $serviceMethodsMap; } /** * {@inheritdoc} * * @SuppressWarnings(PHPMD.UnusedLocalVariable) */ public function read($scope = null) { $result = []; $connectionName = $this->defaultValueProvider->getConnection(); $connections = [ $connectionName => [ 'name' => $connectionName, 'exchange' => $this->defaultValueProvider->getExchange(), 'disabled' => false, ] ]; foreach ($this->getRemoteServices() as $serviceInterface => $remoteImplementation) { try { $methodsMap = $this->serviceMethodsMap->getMethodsMap($serviceInterface); } catch (\Exception $e) { throw new \LogicException(sprintf('Service interface was expected, "%s" given', $serviceInterface)); } foreach ($methodsMap as $methodName => $returnType) { $topic = $this->reflectionGenerator->generateTopicName($serviceInterface, $methodName); $result[$topic] = [ 'topic' => $topic, 'disabled' => false, 'connections' => $connections, ]; } } return $result; } /** * Get list of remote services declared in DI config. * * @return array */ private function getRemoteServices() { $preferences = $this->objectManagerConfig->getPreferences(); $remoteServices = []; foreach ($preferences as $type => $preference) { if ($preference == $type . RemoteServiceGenerator::REMOTE_SERVICE_SUFFIX) { $remoteServices[$type] = $preference; } } return $remoteServices; } }