SiteSettingType   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 0
loc 36
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B buildForm() 0 25 1
A configureOptions() 0 7 1
1
<?php
2
3
namespace Loevgaard\DandomainAltapayBundle\Form;
4
5
use Loevgaard\DandomainAltapayBundle\Entity\SiteSetting;
6
use Symfony\Component\Form\AbstractType;
7
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
8
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
9
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
10
use Symfony\Component\Form\FormBuilderInterface;
11
use Symfony\Component\OptionsResolver\OptionsResolver;
12
13
class SiteSettingType extends AbstractType
14
{
15
    public function buildForm(FormBuilderInterface $builder, array $options)
16
    {
17
        $builder
18
            ->setMethod('POST')
19
            ->add('siteId', null, [
20
                'label' => 'site_setting.label.site_id',
21
            ])
22
            ->add('setting', ChoiceType::class, [
23
                'label' => 'site_setting.label.setting',
24
                'choices' => SiteSetting::getSettings(),
25
                'choice_label' => function ($value, $key, $index) {
0 ignored issues
show
Unused Code introduced by
The parameter $index is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
26
                    return SiteSetting::SETTING_TRANSLATION_PREFIX.$key;
27
                },
28
            ])
29
            ->add('val', TextareaType::class, [
30
                'label' => 'site_setting.label.val',
31
            ])
32
            /*
33
             * Save button
34
             */
35
            ->add('save', SubmitType::class, [
36
                'label' => 'layout.save',
37
            ])
38
        ;
39
    }
40
41
    public function configureOptions(OptionsResolver $resolver)
42
    {
43
        $resolver->setDefaults([
44
            'data_class' => SiteSetting::class,
45
            'translation_domain' => 'LoevgaardDandomainAltapayBundle',
46
        ]);
47
    }
48
}
49