Completed
Push — master ( 0f3db4...6e7c4d )
by Guillaume
16:16
created

KeyValueType::configureOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
3
namespace Maikuro\DistributedConfigurationBundle\Form;
4
5
use Symfony\Component\Form\AbstractType;
6
use Symfony\Component\Form\FormBuilderInterface;
7
use Symfony\Component\OptionsResolver\OptionsResolver;
8
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
9
10
/**
11
 * Class KeyValueType.
12
 */
13
class KeyValueType extends AbstractType
14
{
15
    /**
16
     * @param FormBuilderInterface $builder
17
     * @param array                $options
18
     */
19
    public function buildForm(FormBuilderInterface $builder, array $options)
20
    {
21
        $builder
22
            ->add('key')
23
            ->add('value')
24
        ;
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     * BC for SF < 2.7
30
     */
31
    public function setDefaultOptions(OptionsResolverInterface $resolver)
32
    {
33
        $this->configureOptions($resolver);
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function configureOptions(OptionsResolver $resolver)
40
    {
41
        $resolver->setDefaults([
42
            'data_class' => 'Maikuro\DistributedConfigurationBundle\Model\KeyValue',
43
            'csrf_protection' => false,
44
        ]);
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     * BC for SF < 3.0
50
     */
51
    public function getName()
52
    {
53
        return $this->getBlockPrefix();
54
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
59
    public function getBlockPrefix()
60
    {
61
        return 'key_value';
62
    }
63
}
64