3 namespace Wallabag\CoreBundle\Form\Type
;
5 use Symfony\Component\Form\AbstractType
;
6 use Symfony\Component\Form\Extension\Core\Type\ChoiceType
;
7 use Symfony\Component\Form\Extension\Core\Type\SubmitType
;
8 use Symfony\Component\Form\FormBuilderInterface
;
9 use Symfony\Component\OptionsResolver\OptionsResolver
;
11 class ConfigType
extends AbstractType
14 private $languages = [];
17 * @param array $themes Themes come from the LiipThemeBundle (liip_theme.themes)
18 * @param array $languages Languages come from configuration, array just code language as key and label as value
20 public function __construct($themes, $languages)
22 $this->themes
= array_combine(
24 array_map(function ($s) { return ucwords(strtolower(str_replace('-', ' ', $s
))); }, $themes)
27 $this->languages
= $languages;
30 public function buildForm(FormBuilderInterface
$builder, array $options)
33 ->add('theme', ChoiceType
::class, [
34 'choices' => array_flip($this->themes
),
35 'label' => 'config.form_settings.theme_label',
37 ->add('items_per_page', null, [
38 'label' => 'config.form_settings.items_per_page_label',
40 ->add('reading_speed', ChoiceType
::class, [
41 'label' => 'config.form_settings.reading_speed.label',
43 'config.form_settings.reading_speed.100_word' => '0.5',
44 'config.form_settings.reading_speed.200_word' => '1',
45 'config.form_settings.reading_speed.300_word' => '1.5',
46 'config.form_settings.reading_speed.400_word' => '2',
49 ->add('language', ChoiceType
::class, [
50 'choices' => array_flip($this->languages
),
51 'label' => 'config.form_settings.language_label',
53 ->add('save', SubmitType
::class, [
54 'label' => 'config.form.save',
59 public function configureOptions(OptionsResolver
$resolver)
61 $resolver->setDefaults([
62 'data_class' => 'Wallabag\CoreBundle\Entity\Config',
66 public function getBlockPrefix()