Completed
Push — master ( 4c7b9c...e919dc )
by Kamil
21:11
created

getSubscribedEvents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 6
rs 9.4285
c 1
b 0
f 1
cc 1
eloc 3
nc 1
nop 0
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\CoreBundle\Form\EventSubscriber;
13
14
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
15
use Symfony\Component\Form\FormEvent;
16
use Symfony\Component\Form\FormEvents;
17
use Symfony\Component\Translation\TranslatorInterface;
18
use Symfony\Component\Validator\Constraints\NotBlank;
19
20
/**
21
 * @author Anna Walasek <[email protected]>
22
 */
23
class AddPaymentMethodsFormSubscriber implements EventSubscriberInterface
24
{
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public static function getSubscribedEvents()
29
    {
30
        return [
31
            FormEvents::PRE_SET_DATA => 'preSetData',
32
        ];
33
    }
34
35
    /**
36
     * @param FormEvent $event
37
     */
38
    public function preSetData(FormEvent $event)
39
    {
40
        $form = $event->getForm();
41
        $payment = $event->getData();
42
43
        $form->add('method', 'sylius_payment_method_choice', [
44
            'label' => 'sylius.form.checkout.payment_method',
45
            'subject' => $payment,
46
            'expanded' => true,
47
        ]);
48
    }
49
}
50