Completed
Push — master ( 1f454c...9af5c7 )
by Michał
22s
created

ApiCustomerType::buildForm()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
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\ApiBundle\Form\Extension;
13
14
use Sylius\Bundle\ApiBundle\Form\EventSubscriber\AddUserFormSubscriber;
15
use Sylius\Bundle\CoreBundle\Form\Type\User\ShopUserType;
16
use Sylius\Bundle\CustomerBundle\Form\Type\CustomerGroupChoiceType;
17
use Sylius\Bundle\CustomerBundle\Form\Type\CustomerProfileType;
18
use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType;
19
use Symfony\Component\Form\FormBuilderInterface;
20
use Symfony\Component\Validator\Constraints\Valid;
21
22
/**
23
 * @author Anna Walasek <[email protected]>
24
 */
25
final class ApiCustomerType extends AbstractResourceType
26
{
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function buildForm(FormBuilderInterface $builder, array $options)
31
    {
32
        parent::buildForm($builder, $options);
33
34
        $builder
35
            ->add('group', CustomerGroupChoiceType::class, [
36
                'required' => false,
37
            ])
38
        ;
39
40
        $builder->addEventSubscriber(new AddUserFormSubscriber(ShopUserType::class));
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function getParent()
47
    {
48
        return CustomerProfileType::class;
49
    }
50
}
51