Completed
Push — master ( 61c842...2ec63c )
by Paweł
293:00 queued 278:23
created

LegacyProductType::buildForm()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 29
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 2
Metric Value
c 2
b 0
f 2
dl 0
loc 29
rs 8.8571
cc 1
eloc 22
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\ProductBundle\Form\Type;
13
14
use Sylius\Bundle\ResourceBundle\Form\EventSubscriber\AddCodeFormSubscriber;
15
use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType;
16
use Symfony\Component\Form\FormBuilderInterface;
17
18
/**
19
 * @author Paweł Jędrzejewski <[email protected]>
20
 * @author Gonzalo Vilaseca <[email protected]>
21
 */
22
class LegacyProductType extends AbstractResourceType
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function buildForm(FormBuilderInterface $builder, array $options)
28
    {
29
        $builder
30
            ->add('masterVariant', 'sylius_product_variant', [
31
                'master' => true,
32
            ])
33
            ->add('attributes', 'collection', [
34
                'required' => false,
35
                'type' => 'sylius_product_attribute_value',
36
                'prototype' => false,
37
                'allow_add' => true,
38
                'allow_delete' => true,
39
                'by_reference' => false,
40
            ])
41
            ->add('associations', 'collection', [
42
                'type' => 'sylius_product_association',
43
                'allow_add' => true,
44
                'allow_delete' => true,
45
                'by_reference' => false,
46
                'button_add_label' => 'sylius.ui.add_association',
47
            ])
48
            ->add('options', 'sylius_product_option_choice', [
49
                'required' => false,
50
                'multiple' => true,
51
                'label' => 'sylius.form.product.options',
52
            ])
53
            ->addEventSubscriber(new AddCodeFormSubscriber())
54
        ;
55
    }
56
57
    /**
58
     * {@inheritdoc}
59
     */
60
    public function getName()
61
    {
62
        return 'sylius_product_legacy';
63
    }
64
}
65