Issues (359)

src/SprykerEco/Yves/CrefoPay/Form/BillSubForm.php (1 issue)

1
<?php
2
3
/**
4
 * MIT License
5
 * For full license information, please view the LICENSE file that was distributed with this source code.
6
 */
7
8
namespace SprykerEco\Yves\CrefoPay\Form;
9
10
use Generated\Shared\Transfer\CrefoPayPaymentTransfer;
0 ignored issues
show
The type Generated\Shared\Transfer\CrefoPayPaymentTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use Spryker\Yves\StepEngine\Dependency\Form\AbstractSubFormType;
12
use Spryker\Yves\StepEngine\Dependency\Form\SubFormInterface;
13
use Spryker\Yves\StepEngine\Dependency\Form\SubFormProviderNameInterface;
14
use SprykerEco\Shared\CrefoPay\CrefoPayConfig;
15
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
16
use Symfony\Component\Form\FormBuilderInterface;
17
use Symfony\Component\Form\FormInterface;
18
use Symfony\Component\Form\FormView;
19
use Symfony\Component\OptionsResolver\OptionsResolver;
20
21
/**
22
 * @method \SprykerEco\Yves\CrefoPay\CrefoPayConfig getConfig()
23
 */
24
class BillSubForm extends AbstractSubFormType implements SubFormInterface, SubFormProviderNameInterface
25
{
26
    /**
27
     * @var string
28
     */
29
    public const CREFO_PAY_SHOP_PUBLIC_KEY = 'shopPublicKey';
30
31
    /**
32
     * @var string
33
     */
34
    public const CREFO_PAY_ORDER_ID = 'orderID';
35
36
    /**
37
     * @var string
38
     */
39
    public const CREFO_PAY_SECURE_FIELDS_API_ENDPOINT = 'secureFieldsApiEndpoint';
40
41
    /**
42
     * @var string
43
     */
44
    public const CREFO_PAY_SECURE_FIELDS_PLACEHOLDERS = 'secureFieldsPlaceholders';
45
46
    /**
47
     * @var string
48
     */
49
    protected const PAYMENT_METHOD = 'bill';
50
51
    /**
52
     * @var string
53
     */
54
    protected const FORM_FIELD_PAYMENT_METHOD = 'paymentMethod';
55
56
    /**
57
     * @var string
58
     */
59
    protected const FORM_FIELD_PAYMENT_METHOD_DATA = 'BILL';
60
61
    /**
62
     * @return string
63
     */
64
    public function getProviderName(): string
65
    {
66
        return CrefoPayConfig::PROVIDER_NAME;
67
    }
68
69
    /**
70
     * @return string
71
     */
72
    public function getName(): string
73
    {
74
        return CrefoPayConfig::CREFO_PAY_PAYMENT_METHOD_BILL;
75
    }
76
77
    /**
78
     * @return string
79
     */
80
    public function getPropertyPath(): string
81
    {
82
        return CrefoPayConfig::CREFO_PAY_PAYMENT_METHOD_BILL;
83
    }
84
85
    /**
86
     * @return string
87
     */
88
    public function getTemplatePath(): string
89
    {
90
        return CrefoPayConfig::PROVIDER_NAME . DIRECTORY_SEPARATOR . static::PAYMENT_METHOD;
91
    }
92
93
    /**
94
     * @param \Symfony\Component\OptionsResolver\OptionsResolver $resolver
95
     *
96
     * @return void
97
     */
98
    public function configureOptions(OptionsResolver $resolver): void
99
    {
100
        $resolver->setDefaults([
101
            'data_class' => CrefoPayPaymentTransfer::class,
102
        ])->setRequired(static::OPTIONS_FIELD_NAME);
103
    }
104
105
    /**
106
     * @param \Symfony\Component\Form\FormView $view The view
107
     * @param \Symfony\Component\Form\FormInterface $form The form
108
     * @param array $options The options
109
     *
110
     * @return void
111
     */
112
    public function buildView(FormView $view, FormInterface $form, array $options): void
113
    {
114
        parent::buildView($view, $form, $options);
115
        $selectedOptions = $options[static::OPTIONS_FIELD_NAME];
116
        $view->vars[static::CREFO_PAY_SHOP_PUBLIC_KEY] = $selectedOptions[static::CREFO_PAY_SHOP_PUBLIC_KEY];
117
        $view->vars[static::CREFO_PAY_ORDER_ID] = $selectedOptions[static::CREFO_PAY_ORDER_ID];
118
        $view->vars[static::CREFO_PAY_SECURE_FIELDS_API_ENDPOINT] = $selectedOptions[static::CREFO_PAY_SECURE_FIELDS_API_ENDPOINT];
119
        $view->vars[static::CREFO_PAY_SECURE_FIELDS_PLACEHOLDERS] = $selectedOptions[static::CREFO_PAY_SECURE_FIELDS_PLACEHOLDERS];
120
    }
121
122
    /**
123
     * @param \Symfony\Component\Form\FormBuilderInterface $builder
124
     * @param array $options
125
     *
126
     * @return void
127
     */
128
    public function buildForm(FormBuilderInterface $builder, array $options): void
129
    {
130
        $this->addPaymentMethod($builder);
131
    }
132
133
    /**
134
     * @param \Symfony\Component\Form\FormBuilderInterface $builder
135
     *
136
     * @return $this
137
     */
138
    protected function addPaymentMethod(FormBuilderInterface $builder)
139
    {
140
        $builder->add(
141
            static::FORM_FIELD_PAYMENT_METHOD,
142
            ChoiceType::class,
143
            [
144
                'choices' => [static::FORM_FIELD_PAYMENT_METHOD_DATA],
145
                'expanded' => true,
146
            ],
147
        );
148
149
        return $this;
150
    }
151
}
152