5
5
*/
6
6
namespace Magento \CustomerSampleData \Model ;
7
7
8
- use Magento \Framework \Setup \SampleData \Context as SampleDataContext ;
9
8
use Magento \Customer \Api \Data \RegionInterface ;
9
+ use Magento \Framework \Serialize \Serializer \Json ;
10
+ use Magento \Framework \Setup \SampleData \Context as SampleDataContext ;
10
11
11
12
/**
12
- * Class Customer
13
13
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
14
14
*/
15
15
class Customer
@@ -50,12 +50,12 @@ class Customer
50
50
protected $ accountManagement ;
51
51
52
52
/**
53
- * @var array $customerDataProfile
53
+ * @var array
54
54
*/
55
55
protected $ customerDataProfile ;
56
56
57
57
/**
58
- * @var array $customerDataAddress
58
+ * @var array
59
59
*/
60
60
protected $ customerDataAddress ;
61
61
@@ -69,9 +69,16 @@ class Customer
69
69
*/
70
70
protected $ dataObjectHelper ;
71
71
72
-
72
+ /**
73
+ * @var \Magento\Framework\App\State
74
+ */
73
75
protected $ appState ;
74
76
77
+ /**
78
+ * @var Json
79
+ */
80
+ private $ serializer ;
81
+
75
82
/**
76
83
* @param SampleDataContext $sampleDataContext
77
84
* @param \Magento\Directory\Model\CountryFactory $countryFactory
@@ -82,6 +89,7 @@ class Customer
82
89
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
83
90
* @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper
84
91
* @param \Magento\Framework\App\State $appState
92
+ * @param Json $serializer
85
93
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
86
94
*/
87
95
public function __construct (
@@ -93,7 +101,8 @@ public function __construct(
93
101
\Magento \Customer \Api \AccountManagementInterface $ accountManagement ,
94
102
\Magento \Store \Model \StoreManagerInterface $ storeManager ,
95
103
\Magento \Framework \Api \DataObjectHelper $ dataObjectHelper ,
96
- \Magento \Framework \App \State $ appState
104
+ \Magento \Framework \App \State $ appState ,
105
+ Json $ serializer = null
97
106
) {
98
107
$ this ->fixtureManager = $ sampleDataContext ->getFixtureManager ();
99
108
$ this ->csvReader = $ sampleDataContext ->getCsvReader ();
@@ -105,10 +114,13 @@ public function __construct(
105
114
$ this ->storeManager = $ storeManager ;
106
115
$ this ->dataObjectHelper = $ dataObjectHelper ;
107
116
$ this ->appState = $ appState ;
117
+ $ this ->serializer = $ serializer ?: \Magento \Framework \App \ObjectManager::getInstance ()->get (Json::class);
108
118
}
109
119
110
120
/**
111
- * {@inheritdoc}
121
+ * Loop through list of fixture files and install sample data
122
+ *
123
+ * @param string[] $fixtures
112
124
*/
113
125
public function install ($ fixtures )
114
126
{
@@ -237,7 +249,7 @@ protected function convertRowData($row, $data)
237
249
foreach ($ row as $ field => $ value ) {
238
250
if (isset ($ data [$ field ])) {
239
251
if ($ field == 'street ' ) {
240
- $ data [$ field ] = unserialize ($ value );
252
+ $ data [$ field ] = $ this -> serializer -> unserialize ($ value );
241
253
continue ;
242
254
}
243
255
if ($ field == 'password ' ) {
0 commit comments