]>
Commit | Line | Data |
---|---|---|
1 | <?php | |
2 | ||
3 | namespace Wallabag\CoreBundle\Form\Type; | |
4 | ||
5 | use Symfony\Component\Form\AbstractType; | |
6 | use Symfony\Component\Form\FormBuilderInterface; | |
7 | use Symfony\Component\OptionsResolver\OptionsResolver; | |
8 | ||
9 | class ConfigType extends AbstractType | |
10 | { | |
11 | private $themes = array(); | |
12 | ||
13 | /** | |
14 | * @param array $themes Themes come from the LiipThemeBundle (liip_theme.themes) | |
15 | */ | |
16 | public function __construct($themes) | |
17 | { | |
18 | $this->themes = array_combine( | |
19 | $themes, | |
20 | array_map(function ($s) { return ucwords(strtolower(str_replace('-', ' ', $s))); }, $themes) | |
21 | ); | |
22 | } | |
23 | ||
24 | public function buildForm(FormBuilderInterface $builder, array $options) | |
25 | { | |
26 | $builder | |
27 | ->add('theme', 'choice', array( | |
28 | 'choices' => array_flip($this->themes), | |
29 | 'choices_as_values' => true, | |
30 | )) | |
31 | ->add('items_per_page') | |
32 | ->add('language') | |
33 | ->add('save', 'submit') | |
34 | ; | |
35 | } | |
36 | ||
37 | public function configureOptions(OptionsResolver $resolver) | |
38 | { | |
39 | $resolver->setDefaults(array( | |
40 | 'data_class' => 'Wallabag\CoreBundle\Entity\Config', | |
41 | )); | |
42 | } | |
43 | ||
44 | public function getName() | |
45 | { | |
46 | return 'config'; | |
47 | } | |
48 | } |