23
23
use Magento \MagentoCloud \Util \UrlManager ;
24
24
use Magento \MagentoCloud \Util \PasswordGenerator ;
25
25
use Magento \MagentoCloud \Config \RemoteStorage ;
26
+ use Magento \MagentoCloud \Config \Amqp as AmqpConfig ;
26
27
27
28
/**
28
29
* Generates command for magento installation
@@ -90,6 +91,11 @@ class InstallCommandFactory
90
91
*/
91
92
private $ remoteStorage ;
92
93
94
+ /**
95
+ * @var AmqpConfig
96
+ */
97
+ private $ amqpConfig ;
98
+
93
99
/**
94
100
* @param UrlManager $urlManager
95
101
* @param AdminDataInterface $adminData
@@ -102,6 +108,7 @@ class InstallCommandFactory
102
108
* @param ElasticSearch $elasticSearch
103
109
* @param OpenSearch $openSearch
104
110
* @param RemoteStorage $remoteStorage
111
+ * @param AmqpConfig $amqpConfig
105
112
*
106
113
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
107
114
*/
@@ -116,7 +123,8 @@ public function __construct(
116
123
MagentoVersion $ magentoVersion ,
117
124
ElasticSearch $ elasticSearch ,
118
125
OpenSearch $ openSearch ,
119
- RemoteStorage $ remoteStorage
126
+ RemoteStorage $ remoteStorage ,
127
+ AmqpConfig $ amqpConfig
120
128
) {
121
129
$ this ->urlManager = $ urlManager ;
122
130
$ this ->adminData = $ adminData ;
@@ -129,6 +137,7 @@ public function __construct(
129
137
$ this ->elasticSearch = $ elasticSearch ;
130
138
$ this ->openSearch = $ openSearch ;
131
139
$ this ->remoteStorage = $ remoteStorage ;
140
+ $ this ->amqpConfig = $ amqpConfig ;
132
141
}
133
142
134
143
/**
@@ -148,7 +157,8 @@ public function create(): string
148
157
$ this ->getBaseOptions (),
149
158
$ this ->getAdminOptions (),
150
159
$ this ->getEsOptions (),
151
- $ this ->getRemoteStorageOptions ()
160
+ $ this ->getRemoteStorageOptions (),
161
+ $ this ->getAmqpOptions ()
152
162
);
153
163
} catch (GenericException $ exception ) {
154
164
throw new ConfigException ($ exception ->getMessage (), $ exception ->getCode (), $ exception );
@@ -334,4 +344,27 @@ private function getConnectionData(): ConnectionInterface
334
344
335
345
return $ this ->connectionData ;
336
346
}
347
+
348
+ /**
349
+ * Returns AMQP optional config options.
350
+ *
351
+ * @return array
352
+ * @throws UndefinedPackageException
353
+ */
354
+ private function getAmqpOptions (): array
355
+ {
356
+ $ options = [];
357
+ $ config = $ this ->amqpConfig ->getConfig ();
358
+ $ map = ['host ' , 'port ' , 'user ' , 'password ' , 'virtualhost ' ];
359
+
360
+ if (!empty ($ config ['amqp ' ]['host ' ])) {
361
+ foreach ($ map as $ option ) {
362
+ if (!empty ($ config ['amqp ' ][$ option ])) {
363
+ $ options ['--amqp- ' . $ option ] = (string )$ config ['amqp ' ][$ option ];
364
+ }
365
+ }
366
+ }
367
+
368
+ return $ options ;
369
+ }
337
370
}
0 commit comments