Skip to content

Commit 79507b6

Browse files
author
Serhiy Shkolyarenko
committed
MAGETWO-48248: [GitHub] Prefix field has wrong type on Checkout #3083
CR fixes
1 parent 59d1577 commit 79507b6

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

app/code/Magento/Checkout/Block/Checkout/LayoutProcessor.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,25 +85,18 @@ private function getAddressAttributes()
8585
/**
8686
* Convert prefix and suffix from inputs to selects when necessary
8787
*
88-
* @param array $elements
88+
* @param array $elements address attributes
89+
* @param array $attributesToConvert fields and their callbacks
8990
* @return array
9091
*/
91-
private function convertPrefixSuffix($elements)
92+
private function convertPrefixSuffix($elements, $attributesToConvert)
9293
{
93-
$attributesToConvert = [
94-
'prefix' => 'getNamePrefixOptions',
95-
'suffix' => 'getNameSuffixOptions',
96-
];
97-
9894
$codes = array_keys($attributesToConvert);
9995
foreach (array_keys($elements) as $code) {
10096
if (!in_array($code, $codes)) {
10197
continue;
10298
}
103-
$options = call_user_func_array(
104-
[$this->getOptions(), $attributesToConvert[$code]],
105-
[]
106-
);
99+
$options = call_user_func($attributesToConvert[$code]);
107100
if (!is_array($options)) {
108101
continue;
109102
}
@@ -129,8 +122,13 @@ private function convertPrefixSuffix($elements)
129122
*/
130123
public function process($jsLayout)
131124
{
125+
$attributesToConvert = [
126+
'prefix' => [$this->getOptions(), 'getNamePrefixOptions'],
127+
'suffix' => [$this->getOptions(), 'getNameSuffixOptions'],
128+
];
129+
132130
$elements = $this->getAddressAttributes();
133-
$elements = $this->convertPrefixSuffix($elements);
131+
$elements = $this->convertPrefixSuffix($elements, $attributesToConvert);
134132
// The following code is a workaround for custom address attributes
135133
if (isset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']
136134
['payment']['children']

0 commit comments

Comments
 (0)