]> git.immae.eu Git - github/wallabag/wallabag.git/blame - src/Wallabag/CoreBundle/Form/Type/ConfigType.php
Symfony Upgrade Fixer FTW
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Form / Type / ConfigType.php
CommitLineData
4d85d7e9 1<?php
4346a860 2
4d85d7e9
J
3namespace Wallabag\CoreBundle\Form\Type;
4
5use Symfony\Component\Form\AbstractType;
619cc453
JB
6use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
7use Symfony\Component\Form\Extension\Core\Type\SubmitType;
4d85d7e9 8use Symfony\Component\Form\FormBuilderInterface;
75e9d1df 9use Symfony\Component\OptionsResolver\OptionsResolver;
4d85d7e9
J
10
11class ConfigType extends AbstractType
12{
32da2a70 13 private $themes = array();
c89d35e8 14 private $languages = array();
32da2a70
J
15
16 /**
c89d35e8
NL
17 * @param array $themes Themes come from the LiipThemeBundle (liip_theme.themes)
18 * @param array $languages Languages come from configuration, array just code language as key and label as value
32da2a70 19 */
c89d35e8 20 public function __construct($themes, $languages)
32da2a70
J
21 {
22 $this->themes = array_combine(
23 $themes,
24 array_map(function ($s) { return ucwords(strtolower(str_replace('-', ' ', $s))); }, $themes)
25 );
c89d35e8
NL
26
27 $this->languages = $languages;
32da2a70
J
28 }
29
4d85d7e9
J
30 public function buildForm(FormBuilderInterface $builder, array $options)
31 {
32 $builder
619cc453 33 ->add('theme', ChoiceType::class, array(
75e9d1df
JB
34 'choices' => array_flip($this->themes),
35 'choices_as_values' => true,
36 ))
371ac69a 37 ->add('items_per_page')
619cc453 38 ->add('language', ChoiceType::class, array(
c89d35e8
NL
39 'choices' => $this->languages,
40 ))
619cc453 41 ->add('save', SubmitType::class)
4d85d7e9
J
42 ;
43 }
44
75e9d1df 45 public function configureOptions(OptionsResolver $resolver)
4d85d7e9
J
46 {
47 $resolver->setDefaults(array(
48 'data_class' => 'Wallabag\CoreBundle\Entity\Config',
49 ));
50 }
51
619cc453 52 public function getBlockPrefix()
4d85d7e9
J
53 {
54 return 'config';
55 }
56}