3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
+ declare (strict_types=1 );
7
+
6
8
namespace Magento \Checkout \Block \Checkout ;
7
9
8
10
use Magento \Checkout \Helper \Data ;
9
- use Magento \Framework \App \ObjectManager ;
11
+ use Magento \Customer \Model \AttributeMetadataDataProvider ;
12
+ use Magento \Customer \Model \Options ;
13
+ use Magento \Eav \Api \Data \AttributeInterface ;
14
+ use Magento \Shipping \Model \Config ;
10
15
use Magento \Store \Model \StoreManagerInterface ;
16
+ use Magento \Ui \Component \Form \AttributeMapper ;
11
17
12
18
/**
13
- * Class LayoutProcessor
19
+ * Checkout Layout Processor
14
20
*/
15
- class LayoutProcessor implements \ Magento \ Checkout \ Block \ Checkout \ LayoutProcessorInterface
21
+ class LayoutProcessor implements LayoutProcessorInterface
16
22
{
17
23
/**
18
- * @var \Magento\Customer\Model\ AttributeMetadataDataProvider
24
+ * @var AttributeMetadataDataProvider
19
25
*/
20
26
private $ attributeMetadataDataProvider ;
21
27
22
28
/**
23
- * @var \Magento\Ui\Component\Form\ AttributeMapper
29
+ * @var AttributeMapper
24
30
*/
25
31
protected $ attributeMapper ;
26
32
@@ -30,7 +36,7 @@ class LayoutProcessor implements \Magento\Checkout\Block\Checkout\LayoutProcesso
30
36
protected $ merger ;
31
37
32
38
/**
33
- * @var \Magento\Customer\Model\ Options
39
+ * @var Options
34
40
*/
35
41
private $ options ;
36
42
@@ -45,39 +51,35 @@ class LayoutProcessor implements \Magento\Checkout\Block\Checkout\LayoutProcesso
45
51
private $ storeManager ;
46
52
47
53
/**
48
- * @var \Magento\Shipping\Model\ Config
54
+ * @var Config
49
55
*/
50
56
private $ shippingConfig ;
51
57
52
58
/**
53
- * @param \Magento\Customer\Model\ AttributeMetadataDataProvider $attributeMetadataDataProvider
54
- * @param \Magento\Ui\Component\Form\ AttributeMapper $attributeMapper
59
+ * @param AttributeMetadataDataProvider $attributeMetadataDataProvider
60
+ * @param AttributeMapper $attributeMapper
55
61
* @param AttributeMerger $merger
56
- * @param \Magento\Customer\Model\ Options|null $options
57
- * @param Data|null $checkoutDataHelper
58
- * @param \Magento\Shipping\Model\ Config|null $shippingConfig
59
- * @param StoreManagerInterface|null $storeManager
62
+ * @param Options $options
63
+ * @param Data $checkoutDataHelper
64
+ * @param Config $shippingConfig
65
+ * @param StoreManagerInterface $storeManager
60
66
*/
61
67
public function __construct (
62
- \ Magento \ Customer \ Model \ AttributeMetadataDataProvider $ attributeMetadataDataProvider ,
63
- \ Magento \ Ui \ Component \ Form \ AttributeMapper $ attributeMapper ,
68
+ AttributeMetadataDataProvider $ attributeMetadataDataProvider ,
69
+ AttributeMapper $ attributeMapper ,
64
70
AttributeMerger $ merger ,
65
- \ Magento \ Customer \ Model \ Options $ options = null ,
66
- Data $ checkoutDataHelper = null ,
67
- \ Magento \ Shipping \ Model \ Config $ shippingConfig = null ,
68
- StoreManagerInterface $ storeManager = null
71
+ Options $ options ,
72
+ Data $ checkoutDataHelper ,
73
+ Config $ shippingConfig ,
74
+ StoreManagerInterface $ storeManager
69
75
) {
70
76
$ this ->attributeMetadataDataProvider = $ attributeMetadataDataProvider ;
71
77
$ this ->attributeMapper = $ attributeMapper ;
72
78
$ this ->merger = $ merger ;
73
- $ this ->options = $ options ?: \Magento \Framework \App \ObjectManager::getInstance ()
74
- ->get (\Magento \Customer \Model \Options::class);
75
- $ this ->checkoutDataHelper = $ checkoutDataHelper ?: \Magento \Framework \App \ObjectManager::getInstance ()
76
- ->get (Data::class);
77
- $ this ->shippingConfig = $ shippingConfig ?: \Magento \Framework \App \ObjectManager::getInstance ()
78
- ->get (\Magento \Shipping \Model \Config::class);
79
- $ this ->storeManager = $ storeManager ?: \Magento \Framework \App \ObjectManager::getInstance ()
80
- ->get (StoreManagerInterface::class);
79
+ $ this ->options = $ options ;
80
+ $ this ->checkoutDataHelper = $ checkoutDataHelper ;
81
+ $ this ->shippingConfig = $ shippingConfig ;
82
+ $ this ->storeManager = $ storeManager ;
81
83
}
82
84
83
85
/**
@@ -87,7 +89,7 @@ public function __construct(
87
89
*/
88
90
private function getAddressAttributes ()
89
91
{
90
- /** @var \Magento\Eav\Api\Data\ AttributeInterface[] $attributes */
92
+ /** @var AttributeInterface[] $attributes */
91
93
$ attributes = $ this ->attributeMetadataDataProvider ->loadAttributesCollection (
92
94
'customer_address ' ,
93
95
'customer_register_address '
@@ -157,17 +159,22 @@ public function process($jsLayout)
157
159
$ elements = $ this ->getAddressAttributes ();
158
160
$ elements = $ this ->convertElementsToSelect ($ elements , $ attributesToConvert );
159
161
// The following code is a workaround for custom address attributes
160
- if (isset ($ jsLayout ['components ' ]['checkout ' ]['children ' ]['steps ' ]['children ' ]['billing-step ' ]['children ' ]
161
- ['payment ' ]['children ' ])) {
162
+ if (isset (
163
+ $ jsLayout ['components ' ]['checkout ' ]['children ' ]['steps ' ]['children ' ]['billing-step ' ]['children ' ]['payment ' ]
164
+ ['children ' ]
165
+ )) {
162
166
$ jsLayout ['components ' ]['checkout ' ]['children ' ]['steps ' ]['children ' ]['billing-step ' ]['children ' ]
163
167
['payment ' ]['children ' ] = $ this ->processPaymentChildrenComponents (
164
168
$ jsLayout ['components ' ]['checkout ' ]['children ' ]['steps ' ]['children ' ]['billing-step ' ]['children ' ]
165
169
['payment ' ]['children ' ],
166
170
$ elements
167
171
);
168
172
}
169
- if (isset ($ jsLayout ['components ' ]['checkout ' ]['children ' ]['steps ' ]['children ' ]['shipping-step ' ]['children ' ]
170
- ['step-config ' ]['children ' ]['shipping-rates-validation ' ]['children ' ])) {
173
+
174
+ if (isset (
175
+ $ jsLayout ['components ' ]['checkout ' ]['children ' ]['steps ' ]['children ' ]['shipping-step ' ]['children ' ]
176
+ ['step-config ' ]['children ' ]['shipping-rates-validation ' ]['children ' ]
177
+ )) {
171
178
$ jsLayout ['components ' ]['checkout ' ]['children ' ]['steps ' ]['children ' ]['shipping-step ' ]['children ' ]
172
179
['step-config ' ]['children ' ]['shipping-rates-validation ' ]['children ' ] =
173
180
$ this ->processShippingChildrenComponents (
@@ -176,8 +183,10 @@ public function process($jsLayout)
176
183
);
177
184
}
178
185
179
- if (isset ($ jsLayout ['components ' ]['checkout ' ]['children ' ]['steps ' ]['children ' ]['shipping-step ' ]
180
- ['children ' ]['shippingAddress ' ]['children ' ]['shipping-address-fieldset ' ]['children ' ])) {
186
+ if (isset (
187
+ $ jsLayout ['components ' ]['checkout ' ]['children ' ]['steps ' ]['children ' ]['shipping-step ' ]['children ' ]
188
+ ['shippingAddress ' ]['children ' ]['shipping-address-fieldset ' ]['children ' ]
189
+ )) {
181
190
$ fields = $ jsLayout ['components ' ]['checkout ' ]['children ' ]['steps ' ]['children ' ]['shipping-step ' ]
182
191
['children ' ]['shippingAddress ' ]['children ' ]['shipping-address-fieldset ' ]['children ' ];
183
192
$ jsLayout ['components ' ]['checkout ' ]['children ' ]['steps ' ]['children ' ]['shipping-step ' ]
@@ -188,6 +197,7 @@ public function process($jsLayout)
188
197
$ fields
189
198
);
190
199
}
200
+
191
201
return $ jsLayout ;
192
202
}
193
203
@@ -304,9 +314,6 @@ private function getBillingAddressComponent($paymentCode, $elements)
304
314
'checkoutProvider ' ,
305
315
'billingAddress ' . $ paymentCode ,
306
316
[
307
- 'country_id ' => [
308
- 'sortOrder ' => 115 ,
309
- ],
310
317
'region ' => [
311
318
'visible ' => false ,
312
319
],
0 commit comments