Completed
Pull Request — 5.6 (#2830)
by Jeroen
14:14
created

Form/Rule/LocaleWhiteListAdminType.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Kunstmaan\LeadGenerationBundle\Form\Rule;
4
5
use Kunstmaan\AdminBundle\Helper\DomainConfigurationInterface;
6
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
7
use Symfony\Component\Form\FormBuilderInterface;
8
9 View Code Duplication
class LocaleWhiteListAdminType extends AbstractRuleAdminType
0 ignored issues
show
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
10
{
11
    private $locales;
12
13
    public function __construct(DomainConfigurationInterface $domainConfiguration)
14
    {
15
        $locales = $domainConfiguration->getFrontendLocales();
16
        $this->locales = array_combine($locales, $locales);
17
    }
18
19
    /**
20
     * Builds the form.
21
     *
22
     * This method is called for each type in the hierarchy starting form the
23
     * top most type. Type extensions can further modify the form.
24
     *
25
     * @see FormTypeExtensionInterface::buildForm()
26
     *
27
     * @param FormBuilderInterface $builder The form builder
28
     * @param array                $options The options
29
     */
30
    public function buildForm(FormBuilderInterface $builder, array $options)
31
    {
32
        $builder->add('locale', ChoiceType::class, [
33
            'label' => 'kuma_lead_generation.form.locale_white_list.locale.label',
34
            'attr' => [
35
                'info_text' => 'kuma_lead_generation.form.locale_white_list.locale.info_text',
36
            ],
37
            'choices' => $this->locales,
38
        ]);
39
    }
40
41
    /**
42
     * Returns the name of this type.
43
     *
44
     * @return string The name of this type
45
     */
46
    public function getBlockPrefix()
47
    {
48
        return 'locale_whitelist_form';
49
    }
50
}
51