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\Payone\Form; |
9
|
|
|
|
10
|
|
|
use Generated\Shared\Transfer\PaymentTransfer; |
11
|
|
|
use Generated\Shared\Transfer\PayonePaymentEWalletTransfer; |
12
|
|
|
use Spryker\Yves\StepEngine\Dependency\Form\SubFormInterface; |
13
|
|
|
use SprykerEco\Shared\Payone\PayoneConstants; |
14
|
|
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; |
15
|
|
|
use Symfony\Component\Form\FormBuilderInterface; |
16
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolver; |
17
|
|
|
|
18
|
|
|
class EWalletSubForm extends AbstractPayoneSubForm |
19
|
|
|
{ |
20
|
|
|
const PAYMENT_METHOD = 'e_wallet'; |
21
|
|
|
const FIELD_WALLET_TYPE = 'wallettype'; |
22
|
|
|
|
23
|
|
|
const OPTION_WALLET_CHOICES = 'wallet_types'; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @return string |
27
|
|
|
*/ |
28
|
|
|
public function getName() |
29
|
|
|
{ |
30
|
|
|
return PaymentTransfer::PAYONE_E_WALLET; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @return string |
35
|
|
|
*/ |
36
|
|
|
public function getPropertyPath() |
37
|
|
|
{ |
38
|
|
|
return PaymentTransfer::PAYONE_E_WALLET; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @return string |
43
|
|
|
*/ |
44
|
|
|
public function getTemplatePath() |
45
|
|
|
{ |
46
|
|
|
return PayoneConstants::PROVIDER_NAME . '/' . self::PAYMENT_METHOD; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @param \Symfony\Component\OptionsResolver\OptionsResolver $resolver |
51
|
|
|
* |
52
|
|
|
* @return void |
53
|
|
|
*/ |
54
|
|
|
public function configureOptions(OptionsResolver $resolver) |
55
|
|
|
{ |
56
|
|
|
$resolver->setDefaults([ |
57
|
|
|
'data_class' => PayonePaymentEWalletTransfer::class, |
58
|
|
|
])->setRequired(SubFormInterface::OPTIONS_FIELD_NAME); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @param \Symfony\Component\OptionsResolver\OptionsResolver $resolver |
63
|
|
|
* |
64
|
|
|
* @return void |
65
|
|
|
*/ |
66
|
|
|
public function setDefaultOptions(OptionsResolver $resolver) |
67
|
|
|
{ |
68
|
|
|
$this->configureOptions($resolver); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @param \Symfony\Component\Form\FormBuilderInterface $builder |
73
|
|
|
* @param array $options |
74
|
|
|
* |
75
|
|
|
* @return void |
76
|
|
|
*/ |
77
|
|
|
public function buildForm(FormBuilderInterface $builder, array $options) |
78
|
|
|
{ |
79
|
|
|
$this->addWalletType($builder, $options[SubFormInterface::OPTIONS_FIELD_NAME][static::OPTION_WALLET_CHOICES]); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @param \Symfony\Component\Form\FormBuilderInterface $builder |
84
|
|
|
* @param array $choices |
85
|
|
|
* |
86
|
|
|
* @return $this |
87
|
|
|
*/ |
88
|
|
|
protected function addWalletType(FormBuilderInterface $builder, array $choices) |
89
|
|
|
{ |
90
|
|
|
$builder->add( |
91
|
|
|
self::FIELD_WALLET_TYPE, |
92
|
|
|
ChoiceType::class, |
93
|
|
|
[ |
94
|
|
|
'label' => false, |
95
|
|
|
'required' => true, |
96
|
|
|
'choices' => $choices, |
97
|
|
|
] |
98
|
|
|
); |
99
|
|
|
|
100
|
|
|
return $this; |
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
|