23 private $defaultValueProvider;
28 private $objectManagerConfig;
33 private $reflectionGenerator;
38 private $serviceMethodsMap;
50 ObjectManagerConfig $objectManagerConfig,
52 ServiceMethodsMap $serviceMethodsMap
54 $this->defaultValueProvider = $defaultValueProvider;
55 $this->objectManagerConfig = $objectManagerConfig;
56 $this->reflectionGenerator = $reflectionGenerator;
57 $this->serviceMethodsMap = $serviceMethodsMap;
63 public function read($scope =
null)
65 $exchangeName = $this->defaultValueProvider->getExchange();
68 'name' => $exchangeName,
70 'connection' => $this->defaultValueProvider->getConnection(),
72 'autoDelete' =>
false,
74 'bindings' => $this->generateBindings(),
89 private function generateBindings()
92 foreach ($this->getRemoteServices() as $serviceInterface => $remoteImplementation) {
94 $methodsMap = $this->serviceMethodsMap->getMethodsMap($serviceInterface);
95 }
catch (\Exception $e) {
96 throw new \LogicException(sprintf(
'Service interface was expected, "%s" given', $serviceInterface));
98 foreach ($methodsMap as $methodName => $returnType) {
99 $topic = $this->reflectionGenerator->generateTopicName($serviceInterface, $methodName);
100 $exchangeName = $this->defaultValueProvider->getExchange();
101 $destination =
'queue.' . $topic;
102 $id = $topic .
'--' . $exchangeName .
'--' . $destination;
105 'destinationType' =>
'queue',
106 'destination' => $destination,
121 private function getRemoteServices()
123 $preferences = $this->objectManagerConfig->getPreferences();
124 $remoteServices = [];
125 foreach ($preferences as
$type => $preference) {
126 if ($preference ==
$type . RemoteServiceGenerator::REMOTE_SERVICE_SUFFIX) {
127 $remoteServices[
$type] = $preference;
130 return $remoteServices;
__construct(DefaultValueProvider $defaultValueProvider, ObjectManagerConfig $objectManagerConfig, ReflectionGenerator $reflectionGenerator, ServiceMethodsMap $serviceMethodsMap)