]>
Commit | Line | Data |
---|---|---|
4d85d7e9 | 1 | <?php |
4346a860 | 2 | |
4d85d7e9 J |
3 | namespace Wallabag\CoreBundle\Form\Type; |
4 | ||
5 | use Symfony\Component\Form\AbstractType; | |
6 | use Symfony\Component\Form\FormBuilderInterface; | |
7 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; | |
8 | ||
9 | class ConfigType extends AbstractType | |
10 | { | |
32da2a70 J |
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 | ||
4d85d7e9 J |
24 | public function buildForm(FormBuilderInterface $builder, array $options) |
25 | { | |
26 | $builder | |
32da2a70 | 27 | ->add('theme', 'choice', array('choices' => $this->themes)) |
371ac69a | 28 | ->add('items_per_page') |
4d85d7e9 J |
29 | ->add('language') |
30 | ->add('save', 'submit') | |
31 | ; | |
32 | } | |
33 | ||
34 | public function setDefaultOptions(OptionsResolverInterface $resolver) | |
35 | { | |
36 | $resolver->setDefaults(array( | |
37 | 'data_class' => 'Wallabag\CoreBundle\Entity\Config', | |
38 | )); | |
39 | } | |
40 | ||
41 | public function getName() | |
42 | { | |
43 | return 'config'; | |
44 | } | |
45 | } |