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