1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the Spryker Commerce OS. |
5
|
|
|
* For full license information, please view the LICENSE file that was distributed with this source code. |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace Pyz\Yves\CheckoutPage; |
9
|
|
|
|
10
|
|
|
use Generated\Shared\Transfer\PaymentTransfer; |
11
|
|
|
use Spryker\Shared\DummyMarketplacePayment\DummyMarketplacePaymentConfig; |
12
|
|
|
use Spryker\Shared\Kernel\Container\GlobalContainer; |
13
|
|
|
use Spryker\Shared\Nopayment\NopaymentConfig; |
14
|
|
|
use Spryker\Yves\DummyMarketplacePayment\Plugin\StepEngine\DummyMarketplacePaymentHandlerPlugin; |
15
|
|
|
use Spryker\Yves\DummyMarketplacePayment\Plugin\StepEngine\SubForm\DummyMarketplacePaymentInvoiceSubFormPlugin; |
16
|
|
|
use Spryker\Yves\Kernel\Container; |
17
|
|
|
use Spryker\Yves\MerchantShipment\Plugin\CheckoutPage\MerchantShipmentCheckoutPageStepEnginePreRenderPlugin; |
18
|
|
|
use Spryker\Yves\Nopayment\Plugin\NopaymentHandlerPlugin; |
19
|
|
|
use Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface; |
20
|
|
|
use Spryker\Yves\StepEngine\Dependency\Plugin\Form\SubFormPluginCollection; |
21
|
|
|
use Spryker\Yves\StepEngine\Dependency\Plugin\Handler\StepHandlerPluginCollection; |
22
|
|
|
use Spryker\Yves\StepEngine\Dependency\Plugin\Handler\StepHandlerPluginInterface; |
23
|
|
|
use SprykerShop\Yves\CheckoutPage\CheckoutPageDependencyProvider as SprykerShopCheckoutPageDependencyProvider; |
24
|
|
|
use SprykerShop\Yves\CheckoutPage\Plugin\StepEngine\PaymentForeignHandlerPlugin; |
25
|
|
|
use SprykerShop\Yves\CustomerPage\Form\CheckoutAddressCollectionForm; |
26
|
|
|
use SprykerShop\Yves\CustomerPage\Form\CustomerCheckoutForm; |
27
|
|
|
use SprykerShop\Yves\CustomerPage\Form\GuestForm; |
28
|
|
|
use SprykerShop\Yves\CustomerPage\Form\LoginForm; |
29
|
|
|
use SprykerShop\Yves\CustomerPage\Form\RegisterForm; |
30
|
|
|
use SprykerShop\Yves\CustomerPage\Plugin\CheckoutPage\CheckoutAddressFormDataProviderPlugin; |
31
|
|
|
use SprykerShop\Yves\CustomerPage\Plugin\CheckoutPage\CustomerAddressExpanderPlugin; |
32
|
|
|
use SprykerShop\Yves\CustomerPage\Plugin\CustomerStepHandler; |
33
|
|
|
use SprykerShop\Yves\PaymentAppWidget\Plugin\CheckoutPage\PaymentAppExpressCheckoutWorkflowCheckoutStepResolverStrategyPlugin; |
34
|
|
|
use SprykerShop\Yves\PaymentPage\Plugin\PaymentPage\PaymentForeignPaymentCollectionExtenderPlugin; |
35
|
|
|
use SprykerShop\Yves\SalesOrderThresholdWidget\Plugin\CheckoutPage\SalesOrderThresholdWidgetPlugin; |
36
|
|
|
use SprykerShop\Yves\ServicePointCartPage\Plugin\CartPage\ServicePointCheckoutAddressStepPostExecutePlugin; |
37
|
|
|
use SprykerShop\Yves\ShipmentTypeWidget\Plugin\CheckoutPage\ShipmentTypeCheckoutPageStepEnginePreRenderPlugin; |
38
|
|
|
use Symfony\Component\Form\FormFactory; |
39
|
|
|
use Symfony\Component\Form\FormInterface; |
40
|
|
|
|
41
|
|
|
class CheckoutPageDependencyProvider extends SprykerShopCheckoutPageDependencyProvider |
42
|
|
|
{ |
43
|
|
|
/** |
44
|
|
|
* @uses \Spryker\Yves\Form\Plugin\Application\FormApplicationPlugin::SERVICE_FORM_FACTORY |
45
|
|
|
* |
46
|
|
|
* @var string |
47
|
|
|
*/ |
48
|
|
|
protected const SERVICE_FORM_FACTORY = 'form.factory'; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @param \Spryker\Yves\Kernel\Container $container |
52
|
|
|
* |
53
|
|
|
* @return \Spryker\Yves\Kernel\Container |
54
|
|
|
*/ |
55
|
|
|
public function provideDependencies(Container $container): Container |
56
|
|
|
{ |
57
|
|
|
$container = parent::provideDependencies($container); |
58
|
|
|
$container = $this->extendPaymentMethodHandler($container); |
59
|
|
|
$container = $this->extendSubFormPluginCollection($container); |
60
|
|
|
|
61
|
|
|
return $container; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @return array<string> |
66
|
|
|
*/ |
67
|
|
|
protected function getSummaryPageWidgetPlugins(): array |
68
|
|
|
{ |
69
|
|
|
return [ |
70
|
|
|
SalesOrderThresholdWidgetPlugin::class, #SalesOrderThresholdFeature |
71
|
|
|
]; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @phpstan-return array<class-string<\Symfony\Component\Form\FormTypeInterface>|\Symfony\Component\Form\FormInterface> |
76
|
|
|
* |
77
|
|
|
* @return array<\Symfony\Component\Form\FormTypeInterface|string> |
78
|
|
|
*/ |
79
|
|
|
protected function getCustomerStepSubForms(): array |
80
|
|
|
{ |
81
|
|
|
return [ |
|
|
|
|
82
|
|
|
LoginForm::class, |
83
|
|
|
$this->getCustomerCheckoutForm(RegisterForm::class, RegisterForm::BLOCK_PREFIX), |
84
|
|
|
$this->getCustomerCheckoutForm(GuestForm::class, GuestForm::BLOCK_PREFIX), |
85
|
|
|
]; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @param string $subForm |
90
|
|
|
* @param string $blockPrefix |
91
|
|
|
* |
92
|
|
|
* @return \Symfony\Component\Form\FormInterface |
93
|
|
|
*/ |
94
|
|
|
protected function getCustomerCheckoutForm($subForm, $blockPrefix): FormInterface |
95
|
|
|
{ |
96
|
|
|
return $this->getFormFactory()->createNamed( |
97
|
|
|
$blockPrefix, |
98
|
|
|
CustomerCheckoutForm::class, |
99
|
|
|
null, |
100
|
|
|
[CustomerCheckoutForm::SUB_FORM_CUSTOMER => $subForm], |
101
|
|
|
); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @return \Symfony\Component\Form\FormFactory |
106
|
|
|
*/ |
107
|
|
|
protected function getFormFactory(): FormFactory |
108
|
|
|
{ |
109
|
|
|
return (new GlobalContainer())->get(static::SERVICE_FORM_FACTORY); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @return array<string> |
114
|
|
|
*/ |
115
|
|
|
protected function getAddressStepSubForms(): array |
116
|
|
|
{ |
117
|
|
|
return [ |
118
|
|
|
CheckoutAddressCollectionForm::class, |
119
|
|
|
]; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @param \Spryker\Yves\Kernel\Container $container |
124
|
|
|
* |
125
|
|
|
* @return \Spryker\Yves\Kernel\Container |
126
|
|
|
*/ |
127
|
|
|
protected function extendPaymentMethodHandler(Container $container): Container |
128
|
|
|
{ |
129
|
|
|
$container->extend(static::PAYMENT_METHOD_HANDLER, function (StepHandlerPluginCollection $paymentMethodHandler) { |
130
|
|
|
$paymentMethodHandler->add(new NopaymentHandlerPlugin(), NopaymentConfig::PAYMENT_PROVIDER_NAME); |
131
|
|
|
$paymentMethodHandler->add( |
132
|
|
|
new DummyMarketplacePaymentHandlerPlugin(), |
133
|
|
|
DummyMarketplacePaymentConfig::PAYMENT_METHOD_DUMMY_MARKETPLACE_PAYMENT_INVOICE, |
134
|
|
|
); |
135
|
|
|
$paymentMethodHandler->add(new PaymentForeignHandlerPlugin(), PaymentTransfer::FOREIGN_PAYMENTS); |
136
|
|
|
|
137
|
|
|
return $paymentMethodHandler; |
138
|
|
|
}); |
139
|
|
|
|
140
|
|
|
return $container; |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* @param \Spryker\Yves\Kernel\Container $container |
145
|
|
|
* |
146
|
|
|
* @return \Spryker\Yves\Kernel\Container |
147
|
|
|
*/ |
148
|
|
|
protected function extendSubFormPluginCollection(Container $container): Container |
149
|
|
|
{ |
150
|
|
|
$container->extend(static::PAYMENT_SUB_FORMS, function (SubFormPluginCollection $paymentSubFormPluginCollection) { |
151
|
|
|
$paymentSubFormPluginCollection->add(new DummyMarketplacePaymentInvoiceSubFormPlugin()); |
152
|
|
|
|
153
|
|
|
return $paymentSubFormPluginCollection; |
154
|
|
|
}); |
155
|
|
|
|
156
|
|
|
return $container; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* @return array<\SprykerShop\Yves\CheckoutPageExtension\Dependency\Plugin\AddressTransferExpanderPluginInterface> |
161
|
|
|
*/ |
162
|
|
|
protected function getAddressStepExecutorAddressExpanderPlugins(): array |
163
|
|
|
{ |
164
|
|
|
return [ |
165
|
|
|
new CustomerAddressExpanderPlugin(), |
166
|
|
|
]; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* @return \Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface |
171
|
|
|
*/ |
172
|
|
|
protected function getCheckoutAddressFormDataProviderPlugin(): StepEngineFormDataProviderInterface |
173
|
|
|
{ |
174
|
|
|
return new CheckoutAddressFormDataProviderPlugin(); |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* @return \Spryker\Yves\StepEngine\Dependency\Plugin\Handler\StepHandlerPluginInterface |
179
|
|
|
*/ |
180
|
|
|
protected function getCustomerStepHandler(): StepHandlerPluginInterface |
181
|
|
|
{ |
182
|
|
|
return new CustomerStepHandler(); |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* @return array<\SprykerShop\Yves\CheckoutPageExtension\Dependency\Plugin\StepEngine\CheckoutPageStepEnginePreRenderPluginInterface> |
187
|
|
|
*/ |
188
|
|
|
protected function getCheckoutPageStepEnginePreRenderPlugins(): array |
189
|
|
|
{ |
190
|
|
|
return [ |
191
|
|
|
new MerchantShipmentCheckoutPageStepEnginePreRenderPlugin(), |
192
|
|
|
new ShipmentTypeCheckoutPageStepEnginePreRenderPlugin(), |
193
|
|
|
]; |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
/** |
197
|
|
|
* @return array<\SprykerShop\Yves\CheckoutPageExtension\Dependency\Plugin\PaymentCollectionExtenderPluginInterface> |
198
|
|
|
*/ |
199
|
|
|
protected function getPaymentCollectionExtenderPlugins(): array |
200
|
|
|
{ |
201
|
|
|
return [ |
202
|
|
|
new PaymentForeignPaymentCollectionExtenderPlugin(), |
203
|
|
|
]; |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
/** |
207
|
|
|
* @return list<\SprykerShop\Yves\CheckoutPageExtension\Dependency\Plugin\CheckoutAddressStepPostExecutePluginInterface> |
208
|
|
|
*/ |
209
|
|
|
protected function getCheckoutAddressStepPostExecutePlugins(): array |
210
|
|
|
{ |
211
|
|
|
return [ |
|
|
|
|
212
|
|
|
new ServicePointCheckoutAddressStepPostExecutePlugin(), |
213
|
|
|
]; |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
/** |
217
|
|
|
* @return array<\SprykerShop\Yves\CheckoutPageExtension\Dependency\Plugin\CheckoutStepResolverStrategyPluginInterface> |
218
|
|
|
*/ |
219
|
|
|
protected function getCheckoutStepResolverStrategyPlugins(): array |
220
|
|
|
{ |
221
|
|
|
return [ |
222
|
|
|
new PaymentAppExpressCheckoutWorkflowCheckoutStepResolverStrategyPlugin(), |
223
|
|
|
]; |
224
|
|
|
} |
225
|
|
|
} |
226
|
|
|
|