@@ -41,6 +41,7 @@ protected function _extractCustomerData()
41
41
];
42
42
43
43
$ customerData = $ this ->_extractData (
44
+ $ this ->getRequest (),
44
45
'adminhtml_customer ' ,
45
46
CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER ,
46
47
$ additionalAttributes ,
@@ -61,24 +62,29 @@ protected function _extractCustomerData()
61
62
/**
62
63
* Perform customer data filtration based on form code and form object
63
64
*
65
+ * @param \Magento\Framework\App\RequestInterface $request
64
66
* @param string $formCode The code of EAV form to take the list of attributes from
65
67
* @param string $entityType entity type for the form
66
68
* @param string[] $additionalAttributes The list of attribute codes to skip filtration for
67
69
* @param string $scope scope of the request
68
- * @return array
70
+ * @param \Magento\Customer\Model\Metadata\Form $metadataForm to use for extraction
71
+ * @return array Filtered customer data
72
+ * @SuppressWarnings(PHPMD.NPathComplexity)
69
73
*/
70
74
protected function _extractData (
75
+ \Magento \Framework \App \RequestInterface $ request ,
71
76
$ formCode ,
72
77
$ entityType ,
73
78
$ additionalAttributes = [],
74
- $ scope = null
79
+ $ scope = null ,
80
+ \Magento \Customer \Model \Metadata \Form $ metadataForm = null
75
81
) {
76
- $ metadataForm = $ this ->getMetadataForm ($ entityType , $ formCode , $ scope );
77
- $ formData = $ metadataForm ->extractData ($ this -> getRequest () , $ scope );
82
+ $ metadataForm = $ metadataForm ? $ metadataForm : $ this ->getMetadataForm ($ entityType , $ formCode , $ scope );
83
+ $ formData = $ metadataForm ->extractData ($ request , $ scope );
78
84
79
85
// Initialize additional attributes
80
86
/** @var \Magento\Framework\DataObject $object */
81
- $ object = $ this ->_objectFactory ->create (['data ' => $ this -> getRequest () ->getPostValue ()]);
87
+ $ object = $ this ->_objectFactory ->create (['data ' => $ request ->getPostValue ()]);
82
88
$ requestData = $ object ->getData ($ scope );
83
89
foreach ($ additionalAttributes as $ attributeCode ) {
84
90
$ formData [$ attributeCode ] = isset ($ requestData [$ attributeCode ]) ? $ requestData [$ attributeCode ] : false ;
@@ -123,6 +129,7 @@ protected function saveDefaultFlags(array $addressIdList, array & $extractedCust
123
129
foreach ($ addressIdList as $ addressId ) {
124
130
$ scope = sprintf ('address/%s ' , $ addressId );
125
131
$ addressData = $ this ->_extractData (
132
+ $ this ->getRequest (),
126
133
'adminhtml_customer_address ' ,
127
134
AddressMetadataInterface::ENTITY_TYPE_ADDRESS ,
128
135
['default_billing ' , 'default_shipping ' ],
0 commit comments