@@ -85,25 +85,18 @@ private function getAddressAttributes()
85
85
/**
86
86
* Convert prefix and suffix from inputs to selects when necessary
87
87
*
88
- * @param array $elements
88
+ * @param array $elements address attributes
89
+ * @param array $attributesToConvert fields and their callbacks
89
90
* @return array
90
91
*/
91
- private function convertPrefixSuffix ($ elements )
92
+ private function convertPrefixSuffix ($ elements, $ attributesToConvert )
92
93
{
93
- $ attributesToConvert = [
94
- 'prefix ' => 'getNamePrefixOptions ' ,
95
- 'suffix ' => 'getNameSuffixOptions ' ,
96
- ];
97
-
98
94
$ codes = array_keys ($ attributesToConvert );
99
95
foreach (array_keys ($ elements ) as $ code ) {
100
96
if (!in_array ($ code , $ codes )) {
101
97
continue ;
102
98
}
103
- $ options = call_user_func_array (
104
- [$ this ->getOptions (), $ attributesToConvert [$ code ]],
105
- []
106
- );
99
+ $ options = call_user_func ($ attributesToConvert [$ code ]);
107
100
if (!is_array ($ options )) {
108
101
continue ;
109
102
}
@@ -129,8 +122,13 @@ private function convertPrefixSuffix($elements)
129
122
*/
130
123
public function process ($ jsLayout )
131
124
{
125
+ $ attributesToConvert = [
126
+ 'prefix ' => [$ this ->getOptions (), 'getNamePrefixOptions ' ],
127
+ 'suffix ' => [$ this ->getOptions (), 'getNameSuffixOptions ' ],
128
+ ];
129
+
132
130
$ elements = $ this ->getAddressAttributes ();
133
- $ elements = $ this ->convertPrefixSuffix ($ elements );
131
+ $ elements = $ this ->convertPrefixSuffix ($ elements, $ attributesToConvert );
134
132
// The following code is a workaround for custom address attributes
135
133
if (isset ($ jsLayout ['components ' ]['checkout ' ]['children ' ]['steps ' ]['children ' ]['billing-step ' ]['children ' ]
136
134
['payment ' ]['children ' ]
0 commit comments