@@ -165,7 +165,7 @@ class Settlement extends \Magento\Framework\Model\AbstractModel
165
165
166
166
/**
167
167
* Columns with DateTime data type
168
- *
168
+ *
169
169
* @var array
170
170
*/
171
171
private $ dateTimeColumns = ['transaction_initiation_date ' , 'transaction_completion_date ' ];
@@ -178,15 +178,21 @@ class Settlement extends \Magento\Framework\Model\AbstractModel
178
178
private $ amountColumns = ['gross_transaction_amount ' , 'fee_amount ' ];
179
179
180
180
/**
181
- * @param \Magento\Framework\Model\Context $context
182
- * @param \Magento\Framework\Registry $registry
183
- * @param \Magento\Framework\Filesystem $filesystem
184
- * @param \Magento\Store\Model\StoreManagerInterface $storeManager
185
- * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
186
- * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
187
- * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
188
- * @param array $data
189
- */
181
+ * @var \Magento\Framework\Serialize\Serializer\Json
182
+ */
183
+ private $ serializer ;
184
+
185
+ /**
186
+ * @param \Magento\Framework\Model\Context $context
187
+ * @param \Magento\Framework\Registry $registry
188
+ * @param \Magento\Framework\Filesystem $filesystem
189
+ * @param \Magento\Store\Model\StoreManagerInterface $storeManager
190
+ * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
191
+ * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
192
+ * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
193
+ * @param array $data
194
+ * @param \Magento\Framework\Serialize\Serializer\Json|null $serializer
195
+ */
190
196
public function __construct (
191
197
\Magento \Framework \Model \Context $ context ,
192
198
\Magento \Framework \Registry $ registry ,
@@ -195,12 +201,15 @@ public function __construct(
195
201
\Magento \Framework \App \Config \ScopeConfigInterface $ scopeConfig ,
196
202
\Magento \Framework \Model \ResourceModel \AbstractResource $ resource = null ,
197
203
\Magento \Framework \Data \Collection \AbstractDb $ resourceCollection = null ,
198
- array $ data = []
204
+ array $ data = [],
205
+ \Magento \Framework \Serialize \Serializer \Json $ serializer = null
199
206
) {
200
207
$ this ->_tmpDirectory = $ filesystem ->getDirectoryWrite (DirectoryList::SYS_TMP );
201
208
$ this ->_storeManager = $ storeManager ;
202
209
$ this ->_scopeConfig = $ scopeConfig ;
203
210
parent ::__construct ($ context , $ registry , $ resource , $ resourceCollection , $ data );
211
+ $ this ->serializer = $ serializer ?: \Magento \Framework \App \ObjectManager::getInstance ()
212
+ ->get (\Magento \Framework \Serialize \Serializer \Json::class);
204
213
}
205
214
206
215
/**
@@ -305,14 +314,14 @@ public function fetchAndSave(\Magento\Framework\Filesystem\Io\Sftp $connection)
305
314
public static function createConnection (array $ config )
306
315
{
307
316
if (!isset (
308
- $ config ['hostname ' ]
309
- ) || !isset (
310
- $ config ['username ' ]
311
- ) || !isset (
312
- $ config ['password ' ]
313
- ) || !isset (
314
- $ config ['path ' ]
315
- )
317
+ $ config ['hostname ' ]
318
+ ) || !isset (
319
+ $ config ['username ' ]
320
+ ) || !isset (
321
+ $ config ['password ' ]
322
+ ) || !isset (
323
+ $ config ['path ' ]
324
+ )
316
325
) {
317
326
throw new \InvalidArgumentException ('Required config elements: hostname, username, password, path ' );
318
327
}
@@ -424,7 +433,7 @@ private function getBodyItems(array $line, array $sectionColumns, array $rowMap)
424
433
425
434
/**
426
435
* Format date columns in UTC
427
- *
436
+ *
428
437
* @param string $lineItem
429
438
* @return string
430
439
*/
@@ -574,10 +583,10 @@ public function getSftpCredentials($automaticMode = false)
574
583
$ cfg ['path ' ] = self ::REPORTS_PATH ;
575
584
}
576
585
// avoid duplicates
577
- if (in_array (serialize ($ cfg ), $ uniques )) {
586
+ if (in_array ($ this -> serializer -> serialize ($ cfg ), $ uniques )) {
578
587
continue ;
579
588
}
580
- $ uniques [] = serialize ($ cfg );
589
+ $ uniques [] = $ this -> serializer -> serialize ($ cfg );
581
590
$ configs [] = $ cfg ;
582
591
}
583
592
return $ configs ;
0 commit comments