1 | <?php |
||
30 | final class SwitchLocaleType extends AbstractType |
||
31 | { |
||
32 | /** |
||
33 | * @var \Surfnet\StepupBundle\Form\ChoiceList\LocaleChoiceList |
||
34 | */ |
||
35 | private $localeChoiceList; |
||
36 | |||
37 | /** |
||
38 | * @var \Symfony\Component\Routing\Generator\UrlGeneratorInterface |
||
39 | */ |
||
40 | private $urlGenerator; |
||
41 | |||
42 | public function __construct(LocaleChoiceList $localeChoiceList, UrlGeneratorInterface $urlGenerator) |
||
43 | { |
||
44 | $this->localeChoiceList = $localeChoiceList; |
||
45 | $this->urlGenerator = $urlGenerator; |
||
46 | } |
||
47 | |||
48 | public function buildForm(FormBuilderInterface $builder, array $options) |
||
49 | { |
||
50 | $builder->setAction($this->urlGenerator->generate($options['route'], $options['route_parameters'])); |
||
51 | $builder->setMethod('POST'); |
||
52 | $builder->add('locale', ChoiceType::class, [ |
||
53 | 'label' => /** @Ignore */ false, |
||
54 | 'required' => true, |
||
55 | 'choices' => $this->localeChoiceList->create(), |
||
56 | 'attr' => [ 'class' => 'fa-language' ], |
||
57 | ]); |
||
58 | $builder->add('switch', SubmitType::class, [ |
||
59 | 'label' => 'stepup_middleware_client.form.switch_locale.switch', |
||
60 | 'attr' => [ 'class' => 'btn btn-default' ], |
||
61 | ]); |
||
62 | } |
||
63 | |||
64 | public function configureOptions(OptionsResolver $resolver) |
||
77 | |||
78 | public function getBlockPrefix() |
||
79 | { |
||
82 | } |
||
83 |