1
1
<?php
2
2
/**
3
- *
4
3
* Copyright © Magento, Inc. All rights reserved.
5
4
* See COPYING.txt for license details.
6
5
*/
6
+
7
7
namespace Magento \Customer \Model ;
8
8
9
9
use Magento \Customer \Api \CustomerMetadataInterface ;
10
10
use Magento \Customer \Api \Data \CustomerInterface ;
11
11
use Magento \Customer \Api \GroupManagementInterface ;
12
12
use Magento \Framework \App \RequestInterface ;
13
13
14
+ /**
15
+ * Customer Extractor model.
16
+ */
14
17
class CustomerExtractor
15
18
{
16
19
/**
@@ -60,6 +63,8 @@ public function __construct(
60
63
}
61
64
62
65
/**
66
+ * Creates a Customer object populated with the given form code and request data.
67
+ *
63
68
* @param string $formCode
64
69
* @param RequestInterface $request
65
70
* @param array $attributeValues
@@ -80,23 +85,26 @@ public function extract(
80
85
$ customerData = $ customerForm ->compactData ($ customerData );
81
86
82
87
$ allowedAttributes = $ customerForm ->getAllowedAttributes ();
83
- $ isGroupIdEmpty = isset ($ allowedAttributes ['group_id ' ]);
88
+ $ isGroupIdEmpty = ! isset ($ allowedAttributes ['group_id ' ]);
84
89
85
90
$ customerDataObject = $ this ->customerFactory ->create ();
86
91
$ this ->dataObjectHelper ->populateWithArray (
87
92
$ customerDataObject ,
88
93
$ customerData ,
89
94
\Magento \Customer \Api \Data \CustomerInterface::class
90
95
);
96
+
91
97
$ store = $ this ->storeManager ->getStore ();
98
+ $ storeId = $ store ->getId ();
99
+
92
100
if ($ isGroupIdEmpty ) {
93
101
$ customerDataObject ->setGroupId (
94
- $ this ->customerGroupManagement ->getDefaultGroup ($ store -> getId () )->getId ()
102
+ $ this ->customerGroupManagement ->getDefaultGroup ($ storeId )->getId ()
95
103
);
96
104
}
97
105
98
106
$ customerDataObject ->setWebsiteId ($ store ->getWebsiteId ());
99
- $ customerDataObject ->setStoreId ($ store -> getId () );
107
+ $ customerDataObject ->setStoreId ($ storeId );
100
108
101
109
return $ customerDataObject ;
102
110
}
0 commit comments