1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* MIT License |
5
|
|
|
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace SprykerEco\Yves\Ratepay\Form; |
9
|
|
|
|
10
|
|
|
use Generated\Shared\Transfer\PaymentTransfer; |
|
|
|
|
11
|
|
|
use Generated\Shared\Transfer\RatepayPaymentInstallmentTransfer; |
|
|
|
|
12
|
|
|
use Spryker\Yves\StepEngine\Dependency\Form\SubFormInterface; |
13
|
|
|
use SprykerEco\Shared\Ratepay\RatepayConfig; |
14
|
|
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; |
15
|
|
|
use Symfony\Component\Form\Extension\Core\Type\TextType; |
16
|
|
|
use Symfony\Component\Form\FormBuilderInterface; |
17
|
|
|
use Symfony\Component\Form\FormInterface; |
18
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolver; |
19
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolverInterface; |
|
|
|
|
20
|
|
|
|
21
|
|
|
class InstallmentSubForm extends SubFormAbstract |
22
|
|
|
{ |
23
|
|
|
public const PAYMENT_METHOD = 'installment'; |
24
|
|
|
|
25
|
|
|
public const OPTION_DEBIT_PAY_TYPE = 'debit_pay_type'; |
26
|
|
|
public const OPTION_CALCULATION_TYPE = 'installment_calculation_type'; |
27
|
|
|
public const OPTION_MONTH_ALLOWED = 'interest_month'; |
28
|
|
|
|
29
|
|
|
public const FIELD_INTEREST_RATE = 'interest_rate'; |
30
|
|
|
public const FIELD_INTEREST_RATE_DEFAULT = 'interest_rate_default'; |
31
|
|
|
public const FIELD_BANK_ACCOUNT_HOLDER = 'bank_account_holder'; |
32
|
|
|
public const FIELD_BANK_ACCOUNT_BIC = 'bank_account_bic'; |
33
|
|
|
public const FIELD_BANK_ACCOUNT_IBAN = 'bank_account_iban'; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @param \Symfony\Component\OptionsResolver\OptionsResolver $resolver |
37
|
|
|
* |
38
|
|
|
* @return void |
39
|
|
|
*/ |
40
|
|
|
public function configureOptions(OptionsResolver $resolver) |
41
|
|
|
{ |
42
|
|
|
$resolver->setDefaults([ |
43
|
|
|
'data_class' => RatepayPaymentInstallmentTransfer::class, |
44
|
|
|
SubFormInterface::OPTIONS_FIELD_NAME => [], |
45
|
|
|
'validation_groups' => function (FormInterface $form) { |
46
|
|
|
|
47
|
|
|
if ($form->getParent()[PaymentTransfer::PAYMENT_SELECTION]->getData() != $this->getPropertyPath()) { |
48
|
|
|
return; |
49
|
|
|
} |
50
|
|
|
$data = $form->getData(); |
51
|
|
|
|
52
|
|
|
if ($data->getDebitPayType() == RatepayConfig::DEBIT_PAY_TYPE_DIRECT_DEBIT) { |
53
|
|
|
return [$this->getPropertyPath(), RatepayConfig::DEBIT_PAY_TYPE_DIRECT_DEBIT]; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
return [$this->getPropertyPath()]; |
57
|
|
|
}, |
58
|
|
|
]); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @deprecated Use `configureOptions()` instead. |
63
|
|
|
* |
64
|
|
|
* @param \Symfony\Component\OptionsResolver\OptionsResolverInterface $resolver |
65
|
|
|
* |
66
|
|
|
* @return void |
67
|
|
|
*/ |
68
|
|
|
public function setDefaultOptions(OptionsResolverInterface $resolver) |
69
|
|
|
{ |
70
|
|
|
$this->configureOptions($resolver); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @return string |
75
|
|
|
*/ |
76
|
|
|
public function getPropertyPath() |
77
|
|
|
{ |
78
|
|
|
return RatepayConfig::PAYMENT_METHOD_INSTALLMENT; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @return string |
83
|
|
|
*/ |
84
|
|
|
public function getName() |
85
|
|
|
{ |
86
|
|
|
return RatepayConfig::PAYMENT_METHOD_INSTALLMENT; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @return string |
91
|
|
|
*/ |
92
|
|
|
public function getTemplatePath() |
93
|
|
|
{ |
94
|
|
|
return RatepayConfig::PROVIDER_NAME . '/' . static::PAYMENT_METHOD; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @param \Symfony\Component\Form\FormBuilderInterface $builder |
99
|
|
|
* @param array $options |
100
|
|
|
* |
101
|
|
|
* @return void |
102
|
|
|
*/ |
103
|
|
|
public function buildForm(FormBuilderInterface $builder, array $options) |
104
|
|
|
{ |
105
|
|
|
parent::buildForm($builder, $options); |
106
|
|
|
|
107
|
|
|
$this |
108
|
|
|
->addDebitPayType($builder, $options) |
109
|
|
|
->addCalculationType($builder, $options) |
110
|
|
|
->addBankAccountBic($builder) |
111
|
|
|
->addBankAccountIban($builder) |
112
|
|
|
->addAllowedMonth($builder, $options) |
113
|
|
|
->addInterestRate($builder) |
114
|
|
|
->addInterestRateDefault($builder); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @param \Symfony\Component\Form\FormBuilderInterface $builder |
119
|
|
|
* @param array $options |
120
|
|
|
* |
121
|
|
|
* @return $this |
122
|
|
|
*/ |
123
|
|
|
public function addDebitPayType($builder, array $options) |
124
|
|
|
{ |
125
|
|
|
$builder->add( |
126
|
|
|
self::OPTION_DEBIT_PAY_TYPE, |
127
|
|
|
ChoiceType::class, |
128
|
|
|
[ |
129
|
|
|
'choices' => array_flip($options['select_options'][self::OPTION_DEBIT_PAY_TYPE]), |
130
|
|
|
'label' => false, |
131
|
|
|
'required' => true, |
132
|
|
|
'expanded' => false, |
133
|
|
|
'multiple' => false, |
134
|
|
|
'placeholder' => false, |
135
|
|
|
'constraints' => [ |
136
|
|
|
$this->createNotBlankConstraint(), |
137
|
|
|
], |
138
|
|
|
] |
139
|
|
|
); |
140
|
|
|
|
141
|
|
|
return $this; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* @param \Symfony\Component\Form\FormBuilderInterface $builder |
146
|
|
|
* @param array $options |
147
|
|
|
* |
148
|
|
|
* @return $this |
149
|
|
|
*/ |
150
|
|
|
public function addCalculationType($builder, array $options) |
151
|
|
|
{ |
152
|
|
|
$builder->add( |
153
|
|
|
self::OPTION_CALCULATION_TYPE, |
154
|
|
|
ChoiceType::class, |
155
|
|
|
[ |
156
|
|
|
'choices' => array_flip($options['select_options'][self::OPTION_CALCULATION_TYPE]), |
157
|
|
|
'label' => false, |
158
|
|
|
'required' => true, |
159
|
|
|
'expanded' => false, |
160
|
|
|
'multiple' => false, |
161
|
|
|
'placeholder' => false, |
162
|
|
|
'constraints' => [ |
163
|
|
|
$this->createNotBlankConstraint(), |
164
|
|
|
], |
165
|
|
|
] |
166
|
|
|
); |
167
|
|
|
|
168
|
|
|
return $this; |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* @param \Symfony\Component\Form\FormBuilderInterface $builder |
173
|
|
|
* @param array $options |
174
|
|
|
* |
175
|
|
|
* @return $this |
176
|
|
|
*/ |
177
|
|
|
public function addAllowedMonth($builder, array $options) |
178
|
|
|
{ |
179
|
|
|
$builder->add( |
180
|
|
|
self::OPTION_MONTH_ALLOWED, |
181
|
|
|
ChoiceType::class, |
182
|
|
|
[ |
183
|
|
|
'choices' => array_flip($options['select_options'][self::OPTION_MONTH_ALLOWED]), |
184
|
|
|
'label' => false, |
185
|
|
|
'required' => true, |
186
|
|
|
'expanded' => false, |
187
|
|
|
'multiple' => false, |
188
|
|
|
'placeholder' => false, |
189
|
|
|
'constraints' => [ |
190
|
|
|
$this->createNotBlankConstraint(), |
191
|
|
|
], |
192
|
|
|
] |
193
|
|
|
); |
194
|
|
|
|
195
|
|
|
return $this; |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
/** |
199
|
|
|
* @param \Symfony\Component\Form\FormBuilderInterface $builder |
200
|
|
|
* |
201
|
|
|
* @return $this |
202
|
|
|
*/ |
203
|
|
|
public function addInterestRate($builder) |
204
|
|
|
{ |
205
|
|
|
$builder->add( |
206
|
|
|
self::FIELD_INTEREST_RATE, |
207
|
|
|
TextType::class, |
208
|
|
|
[ |
209
|
|
|
'label' => false, |
210
|
|
|
'constraints' => [], |
211
|
|
|
'attr' => [], |
212
|
|
|
] |
213
|
|
|
); |
214
|
|
|
|
215
|
|
|
return $this; |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
/** |
219
|
|
|
* @param \Symfony\Component\Form\FormBuilderInterface $builder |
220
|
|
|
* |
221
|
|
|
* @return $this |
222
|
|
|
*/ |
223
|
|
|
public function addInterestRateDefault($builder) |
224
|
|
|
{ |
225
|
|
|
$builder->add( |
226
|
|
|
self::FIELD_INTEREST_RATE_DEFAULT, |
227
|
|
|
TextType::class, |
228
|
|
|
[ |
229
|
|
|
'label' => false, |
230
|
|
|
'constraints' => [], |
231
|
|
|
'attr' => [ |
232
|
|
|
'readonly' => 'readonly', |
233
|
|
|
], |
234
|
|
|
] |
235
|
|
|
); |
236
|
|
|
|
237
|
|
|
return $this; |
238
|
|
|
} |
239
|
|
|
|
240
|
|
|
/** |
241
|
|
|
* @param \Symfony\Component\Form\FormBuilderInterface $builder |
242
|
|
|
* |
243
|
|
|
* @return $this |
244
|
|
|
*/ |
245
|
|
|
public function addBankAccountHolder($builder) |
246
|
|
|
{ |
247
|
|
|
$builder->add( |
248
|
|
|
self::FIELD_BANK_ACCOUNT_HOLDER, |
249
|
|
|
TextType::class, |
250
|
|
|
[ |
251
|
|
|
'label' => false, |
252
|
|
|
'required' => false, |
253
|
|
|
'constraints' => [ |
254
|
|
|
$this->createNotBlankConstraint(RatepayConfig::DEBIT_PAY_TYPE_DIRECT_DEBIT), |
255
|
|
|
], |
256
|
|
|
] |
257
|
|
|
); |
258
|
|
|
|
259
|
|
|
return $this; |
260
|
|
|
} |
261
|
|
|
|
262
|
|
|
/** |
263
|
|
|
* @param \Symfony\Component\Form\FormBuilderInterface $builder |
264
|
|
|
* |
265
|
|
|
* @return $this |
266
|
|
|
*/ |
267
|
|
|
public function addBankAccountBic($builder) |
268
|
|
|
{ |
269
|
|
|
$builder->add( |
270
|
|
|
self::FIELD_BANK_ACCOUNT_BIC, |
271
|
|
|
TextType::class, |
272
|
|
|
[ |
273
|
|
|
'label' => false, |
274
|
|
|
'required' => false, |
275
|
|
|
'constraints' => [ |
276
|
|
|
$this->createNotBlankConstraint(RatepayConfig::DEBIT_PAY_TYPE_DIRECT_DEBIT), |
277
|
|
|
], |
278
|
|
|
] |
279
|
|
|
); |
280
|
|
|
|
281
|
|
|
return $this; |
282
|
|
|
} |
283
|
|
|
|
284
|
|
|
/** |
285
|
|
|
* @param \Symfony\Component\Form\FormBuilderInterface $builder |
286
|
|
|
* |
287
|
|
|
* @return $this |
288
|
|
|
*/ |
289
|
|
|
public function addBankAccountIban($builder) |
290
|
|
|
{ |
291
|
|
|
$builder->add( |
292
|
|
|
self::FIELD_BANK_ACCOUNT_IBAN, |
293
|
|
|
TextType::class, |
294
|
|
|
[ |
295
|
|
|
'label' => false, |
296
|
|
|
'required' => false, |
297
|
|
|
'constraints' => [ |
298
|
|
|
$this->createNotBlankConstraint(RatepayConfig::DEBIT_PAY_TYPE_DIRECT_DEBIT), |
299
|
|
|
], |
300
|
|
|
] |
301
|
|
|
); |
302
|
|
|
|
303
|
|
|
return $this; |
304
|
|
|
} |
305
|
|
|
} |
306
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths