55 */
66namespace Magento \CustomerSampleData \Model ;
77
8- use Magento \Framework \Setup \SampleData \Context as SampleDataContext ;
98use Magento \Customer \Api \Data \RegionInterface ;
9+ use Magento \Framework \Serialize \Serializer \Json ;
10+ use Magento \Framework \Setup \SampleData \Context as SampleDataContext ;
1011
1112/**
12- * Class Customer
1313 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1414 */
1515class Customer
@@ -50,12 +50,12 @@ class Customer
5050 protected $ accountManagement ;
5151
5252 /**
53- * @var array $customerDataProfile
53+ * @var array
5454 */
5555 protected $ customerDataProfile ;
5656
5757 /**
58- * @var array $customerDataAddress
58+ * @var array
5959 */
6060 protected $ customerDataAddress ;
6161
@@ -69,9 +69,16 @@ class Customer
6969 */
7070 protected $ dataObjectHelper ;
7171
72-
72+ /**
73+ * @var \Magento\Framework\App\State
74+ */
7375 protected $ appState ;
7476
77+ /**
78+ * @var Json
79+ */
80+ private $ serializer ;
81+
7582 /**
7683 * @param SampleDataContext $sampleDataContext
7784 * @param \Magento\Directory\Model\CountryFactory $countryFactory
@@ -82,6 +89,7 @@ class Customer
8289 * @param \Magento\Store\Model\StoreManagerInterface $storeManager
8390 * @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper
8491 * @param \Magento\Framework\App\State $appState
92+ * @param Json $serializer
8593 * @SuppressWarnings(PHPMD.ExcessiveParameterList)
8694 */
8795 public function __construct (
@@ -93,7 +101,8 @@ public function __construct(
93101 \Magento \Customer \Api \AccountManagementInterface $ accountManagement ,
94102 \Magento \Store \Model \StoreManagerInterface $ storeManager ,
95103 \Magento \Framework \Api \DataObjectHelper $ dataObjectHelper ,
96- \Magento \Framework \App \State $ appState
104+ \Magento \Framework \App \State $ appState ,
105+ Json $ serializer = null
97106 ) {
98107 $ this ->fixtureManager = $ sampleDataContext ->getFixtureManager ();
99108 $ this ->csvReader = $ sampleDataContext ->getCsvReader ();
@@ -105,10 +114,13 @@ public function __construct(
105114 $ this ->storeManager = $ storeManager ;
106115 $ this ->dataObjectHelper = $ dataObjectHelper ;
107116 $ this ->appState = $ appState ;
117+ $ this ->serializer = $ serializer ?: \Magento \Framework \App \ObjectManager::getInstance ()->get (Json::class);
108118 }
109119
110120 /**
111- * {@inheritdoc}
121+ * Loop through list of fixture files and install sample data
122+ *
123+ * @param string[] $fixtures
112124 */
113125 public function install ($ fixtures )
114126 {
@@ -237,7 +249,7 @@ protected function convertRowData($row, $data)
237249 foreach ($ row as $ field => $ value ) {
238250 if (isset ($ data [$ field ])) {
239251 if ($ field == 'street ' ) {
240- $ data [$ field ] = unserialize ($ value );
252+ $ data [$ field ] = $ this -> serializer -> unserialize ($ value );
241253 continue ;
242254 }
243255 if ($ field == 'password ' ) {
0 commit comments