10
10
use Magento \Framework \Filesystem \Driver \File ;
11
11
use Magento \Framework \Module \Dir as ModuleDir ;
12
12
use Magento \Framework \Module \FullModuleList ;
13
+ use Magento \Framework \Module \PackageInfo ;
13
14
use Magento \Framework \Module \ResourceInterface ;
14
15
use Magento \Framework \Serialize \Serializer \Json ;
15
16
use Magento \Framework \UrlInterface ;
@@ -31,6 +32,11 @@ class SupportPackage
31
32
*/
32
33
private $ moduleResource ;
33
34
35
+ /**
36
+ * @var PackageInfo
37
+ */
38
+ private $ packageInfo ;
39
+
34
40
/**
35
41
* @var DeploymentConfig
36
42
*/
@@ -86,6 +92,7 @@ class SupportPackage
86
92
*
87
93
* @param FullModuleList $fullModuleList
88
94
* @param ResourceInterface $moduleResource
95
+ * @param PackageInfo $packageInfo
89
96
* @param DeploymentConfig $deploymentConfig
90
97
* @param ResourceConnection $resourceConnection
91
98
* @param XmlParser $xmlParser
@@ -100,6 +107,7 @@ class SupportPackage
100
107
public function __construct (
101
108
FullModuleList $ fullModuleList ,
102
109
ResourceInterface $ moduleResource ,
110
+ PackageInfo $ packageInfo ,
103
111
DeploymentConfig $ deploymentConfig ,
104
112
ResourceConnection $ resourceConnection ,
105
113
XmlParser $ xmlParser ,
@@ -112,6 +120,7 @@ public function __construct(
112
120
ZipArchive $ zipArchive ,
113
121
) {
114
122
$ this ->moduleResource = $ moduleResource ;
123
+ $ this ->packageInfo = $ packageInfo ;
115
124
$ this ->fullModuleList = $ fullModuleList ;
116
125
$ this ->deploymentConfig = $ deploymentConfig ;
117
126
$ this ->resourceConnection = $ resourceConnection ;
@@ -127,6 +136,8 @@ public function __construct(
127
136
128
137
/**
129
138
* Prepares the support download archive
139
+ *
140
+ * @return string
130
141
*/
131
142
public function prepareDownloadArchive ()
132
143
{
@@ -169,24 +180,36 @@ public function prepareSupportDetails()
169
180
170
181
/**
171
182
* Get the Bitpay module version
183
+ *
184
+ * @return string
172
185
*/
173
186
public function getBitpayModuleVersion ()
174
187
{
175
- return $ this ->moduleResource -> getDbVersion ('Bitpay_BPCheckout ' );
188
+ return $ this ->getModuleVersion ('Bitpay_BPCheckout ' );
176
189
}
177
190
178
191
/**
179
192
* Get the installed modules list
193
+ *
194
+ * @return array
180
195
*/
181
196
public function getModuleList ()
182
197
{
183
198
$ modules = [];
184
199
$ allModules = $ this ->fullModuleList ->getAll ();
185
200
foreach ($ allModules as $ module ) {
201
+ $ schemaVersion = $ this ->moduleResource ->getDbVersion ($ module ['name ' ]);
202
+ $ dataVersion = $ this ->moduleResource ->getDataVersion ($ module ['name ' ]);
203
+ if (empty ($ module ['setup_version ' ])) {
204
+ $ moduleVersion = $ this ->getModuleVersion ($ module ['name ' ]);
205
+ $ schemaVersion = $ moduleVersion ;
206
+ $ dataVersion = $ moduleVersion ;
207
+ }
208
+
186
209
$ modules [] = [
187
210
'name ' => $ module ['name ' ],
188
- 'schema_version ' => $ this -> moduleResource -> getDbVersion ( $ module [ ' name ' ]) ?: 'N/A ' ,
189
- 'data_version ' => $ this -> moduleResource -> getDataVersion ( $ module [ ' name ' ]) ?: 'N/A ' ,
211
+ 'schema_version ' => $ schemaVersion ?: 'N/A ' ,
212
+ 'data_version ' => $ dataVersion ?: 'N/A ' ,
190
213
];
191
214
}
192
215
@@ -195,6 +218,8 @@ public function getModuleList()
195
218
196
219
/**
197
220
* Get the database details
221
+ *
222
+ * @return array
198
223
*/
199
224
public function getDbDetails ()
200
225
{
@@ -278,6 +303,8 @@ public function getDbDetails()
278
303
279
304
/**
280
305
* Get Magento details
306
+ *
307
+ * @return array
281
308
*/
282
309
public function getMagentoDetails ()
283
310
{
@@ -289,6 +316,8 @@ public function getMagentoDetails()
289
316
290
317
/**
291
318
* Get server details
319
+ *
320
+ * @return array
292
321
*/
293
322
public function getServerDetails ()
294
323
{
@@ -306,6 +335,8 @@ public function getServerDetails()
306
335
307
336
/**
308
337
* Get PHP details
338
+ *
339
+ * @return array
309
340
*/
310
341
public function getPhpDetails ()
311
342
{
@@ -324,4 +355,15 @@ public function getPhpDetails()
324
355
'extensions ' => get_loaded_extensions (),
325
356
];
326
357
}
358
+
359
+ /**
360
+ * Get the version of a module
361
+ *
362
+ * @param string $moduleName
363
+ * @return string
364
+ */
365
+ protected function getModuleVersion (string $ moduleName )
366
+ {
367
+ return $ this ->packageInfo ->getVersion ($ moduleName );
368
+ }
327
369
}
0 commit comments