Completed
Push — master ( 9aa2c9...9cd567 )
by Paweł
53:11 queued 43:31
created

PaymentType::buildForm()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 9.2
c 0
b 0
f 0
cc 1
eloc 15
nc 1
nop 2
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sylius\Bundle\PaymentBundle\Form\Type;
13
14
use Sylius\Bundle\MoneyBundle\Form\Type\MoneyType;
15
use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType;
16
use Sylius\Component\Payment\Model\PaymentInterface;
17
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
18
use Symfony\Component\Form\FormBuilderInterface;
19
20
/**
21
 * @author Paweł Jędrzejewski <[email protected]>
22
 */
23
final class PaymentType extends AbstractResourceType
24
{
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function buildForm(FormBuilderInterface $builder, array $options)
29
    {
30
        $builder
31
            ->add('method', PaymentMethodChoiceType::class, [
32
                'label' => 'sylius.form.payment.method',
33
            ])
34
            ->add('amount', MoneyType::class, [
35
                'label' => 'sylius.form.payment.amount',
36
            ])
37
            ->add('state', ChoiceType::class, [
38
                'choices' => [
39
                    'sylius.form.payment.state.processing' => PaymentInterface::STATE_PROCESSING,
40
                    'sylius.form.payment.state.failed' => PaymentInterface::STATE_FAILED,
41
                    'sylius.form.payment.state.completed' => PaymentInterface::STATE_COMPLETED,
42
                    'sylius.form.payment.state.new' => PaymentInterface::STATE_NEW,
43
                    'sylius.form.payment.state.cancelled' => PaymentInterface::STATE_CANCELLED,
44
                    'sylius.form.payment.state.refunded' => PaymentInterface::STATE_REFUNDED,
45
                ],
46
                'label' => 'sylius.form.payment.state.header',
47
            ])
48
        ;
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    public function getBlockPrefix()
55
    {
56
        return 'sylius_payment';
57
    }
58
}
59