]> git.immae.eu Git - github/wallabag/wallabag.git/blame - src/Wallabag/CoreBundle/Form/Type/ConfigType.php
Update to Symfony 2.7
[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;
6use Symfony\Component\Form\FormBuilderInterface;
75e9d1df 7use Symfony\Component\OptionsResolver\OptionsResolver;
4d85d7e9
J
8
9class 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
75e9d1df
JB
27 ->add('theme', 'choice', array(
28 'choices' => array_flip($this->themes),
29 'choices_as_values' => true,
30 ))
371ac69a 31 ->add('items_per_page')
4d85d7e9
J
32 ->add('language')
33 ->add('save', 'submit')
34 ;
35 }
36
75e9d1df 37 public function configureOptions(OptionsResolver $resolver)
4d85d7e9
J
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}