Passed
Push — staging ( 9639f2...81b4f0 )
by
unknown
13:26 queued 10s
created

ContactColumnsType::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
/*
4
 * @copyright   2019 Mautic Contributors. All rights reserved
5
 * @author      Mautic
6
 *
7
 * @link        http://mautic.org
8
 *
9
 * @license     GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
10
 */
11
12
namespace Mautic\LeadBundle\Form\Type;
13
14
use Mautic\LeadBundle\Services\ContactColumnsDictionary;
15
use Symfony\Component\Form\AbstractType;
16
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
17
use Symfony\Component\OptionsResolver\OptionsResolver;
18
19
class ContactColumnsType extends AbstractType
20
{
21
    private $columnsDictionary;
22
23
    /**
24
     * ContactColumnsType constructor.
25
     */
26
    public function __construct(ContactColumnsDictionary $columnsDictionary)
27
    {
28
        $this->columnsDictionary = $columnsDictionary;
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function configureOptions(OptionsResolver $resolver)
35
    {
36
        $resolver->setDefaults(
37
          [
38
              'choices'    => array_flip($this->columnsDictionary->getFields()),
39
              'label'      => false,
40
              'label_attr' => ['class' => 'control-label'],
41
              'required'   => false,
42
              'multiple'   => true,
43
              'expanded'   => false,
44
              'attr'       => [
45
                  'class'         => 'form-control',
46
              ],
47
          ]
48
        );
49
    }
50
51
    /**
52
     * @return string|\Symfony\Component\Form\FormTypeInterface|null
53
     */
54
    public function getParent()
55
    {
56
        return ChoiceType::class;
57
    }
58
}
59