]> git.immae.eu Git - github/wallabag/wallabag.git/blame - src/Wallabag/CoreBundle/Form/Type/ConfigType.php
Improve composer.json
[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 11 private $themes = array();
c89d35e8 12 private $languages = array();
32da2a70
J
13
14 /**
c89d35e8
NL
15 * @param array $themes Themes come from the LiipThemeBundle (liip_theme.themes)
16 * @param array $languages Languages come from configuration, array just code language as key and label as value
32da2a70 17 */
c89d35e8 18 public function __construct($themes, $languages)
32da2a70
J
19 {
20 $this->themes = array_combine(
21 $themes,
22 array_map(function ($s) { return ucwords(strtolower(str_replace('-', ' ', $s))); }, $themes)
23 );
c89d35e8
NL
24
25 $this->languages = $languages;
32da2a70
J
26 }
27
4d85d7e9
J
28 public function buildForm(FormBuilderInterface $builder, array $options)
29 {
30 $builder
75e9d1df
JB
31 ->add('theme', 'choice', array(
32 'choices' => array_flip($this->themes),
33 'choices_as_values' => true,
34 ))
371ac69a 35 ->add('items_per_page')
c89d35e8
NL
36 ->add('language', 'choice', array(
37 'choices' => $this->languages,
38 ))
4d85d7e9
J
39 ->add('save', 'submit')
40 ;
41 }
42
75e9d1df 43 public function configureOptions(OptionsResolver $resolver)
4d85d7e9
J
44 {
45 $resolver->setDefaults(array(
46 'data_class' => 'Wallabag\CoreBundle\Entity\Config',
47 ));
48 }
49
50 public function getName()
51 {
52 return 'config';
53 }
54}