|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace App\Form\Type; |
|
6
|
|
|
|
|
7
|
|
|
use App\Entity\Currency; |
|
8
|
|
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType; |
|
9
|
|
|
use Symfony\Component\Form\AbstractType; |
|
10
|
|
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; |
|
11
|
|
|
use Symfony\Component\Form\Extension\Core\Type\TextareaType; |
|
12
|
|
|
use Symfony\Component\Form\FormBuilderInterface; |
|
13
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolver; |
|
14
|
|
|
use Symfony\Component\Validator\Constraints\Length; |
|
15
|
|
|
use Symfony\Component\Validator\Constraints\Range; |
|
16
|
|
|
|
|
17
|
|
|
final class SettingsType extends AbstractType |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* {@inheritdoc} |
|
21
|
|
|
*/ |
|
22
|
|
|
public function buildForm(FormBuilderInterface $builder, array $options): void |
|
23
|
|
|
{ |
|
24
|
|
|
$builder |
|
25
|
|
|
->add('name', null, [ |
|
26
|
|
|
'attr' => [ |
|
27
|
|
|
'autofocus' => true, |
|
28
|
|
|
], |
|
29
|
|
|
'label' => 'label.settings.name', |
|
30
|
|
|
'constraints' => [new Length(['min' => 2])], |
|
31
|
|
|
]) |
|
32
|
|
|
->add('title', null, [ |
|
33
|
|
|
'label' => 'label.settings.title', |
|
34
|
|
|
'constraints' => [new Length(['min' => 4])], |
|
35
|
|
|
]) |
|
36
|
|
|
->add('meta_title', null, [ |
|
37
|
|
|
'label' => 'label.meta_title', |
|
38
|
|
|
'constraints' => [new Length(['min' => 8])], |
|
39
|
|
|
]) |
|
40
|
|
|
->add('meta_description', TextareaType::class, [ |
|
41
|
|
|
'label' => 'label.meta_description', |
|
42
|
|
|
'constraints' => [new Length(['min' => 8])], |
|
43
|
|
|
]) |
|
44
|
|
|
->add('custom_code', TextareaType::class, [ |
|
45
|
|
|
'required' => false, |
|
46
|
|
|
'label' => 'label.settings.code', |
|
47
|
|
|
]) |
|
48
|
|
|
->add('custom_footer_text', TextareaType::class, [ |
|
49
|
|
|
'required' => false, |
|
50
|
|
|
'label' => 'label.settings.custom_footer_text', |
|
51
|
|
|
]) |
|
52
|
|
|
->add('currency', EntityType::class, [ |
|
53
|
|
|
'class' => Currency::class, |
|
54
|
|
|
'choice_label' => 'currency_title', |
|
55
|
|
|
'label' => 'label.settings.currency', |
|
56
|
|
|
]) |
|
57
|
|
|
->add('items_per_page', null, [ |
|
58
|
|
|
'label' => 'label.settings.limit', |
|
59
|
|
|
'constraints' => [new Range(['min' => 3, 'max' => 100])], |
|
60
|
|
|
]) |
|
61
|
|
|
->add('show_similar_properties', ChoiceType::class, [ |
|
62
|
|
|
'choices' => [ |
|
63
|
|
|
'option.off' => '0', |
|
64
|
|
|
'option.on' => '1', |
|
65
|
|
|
], |
|
66
|
|
|
'label' => 'label.settings.show_similar_properties', |
|
67
|
|
|
] |
|
68
|
|
|
) |
|
69
|
|
|
->add('fixed_top_navbar', ChoiceType::class, [ |
|
70
|
|
|
'choices' => [ |
|
71
|
|
|
'option.off' => '0', |
|
72
|
|
|
'option.on' => '1', |
|
73
|
|
|
], |
|
74
|
|
|
'label' => 'label.settings.fixed_top_navbar', |
|
75
|
|
|
] |
|
76
|
|
|
) |
|
77
|
|
|
->add('show_language_selector', ChoiceType::class, [ |
|
78
|
|
|
'choices' => [ |
|
79
|
|
|
'option.off' => '0', |
|
80
|
|
|
'option.on' => '1', |
|
81
|
|
|
], |
|
82
|
|
|
'label' => 'label.settings.show_language_selector', |
|
83
|
|
|
] |
|
84
|
|
|
) |
|
85
|
|
|
->add('anyone_can_register', ChoiceType::class, [ |
|
86
|
|
|
'choices' => [ |
|
87
|
|
|
'option.off' => '0', |
|
88
|
|
|
'option.on' => '1', |
|
89
|
|
|
], |
|
90
|
|
|
'label' => 'label.settings.anyone_can_register', |
|
91
|
|
|
] |
|
92
|
|
|
) |
|
93
|
|
|
->add('ymaps_key', null, [ |
|
94
|
|
|
'required' => false, |
|
95
|
|
|
'label' => 'label.settings.ymaps_key', |
|
96
|
|
|
]) |
|
97
|
|
|
->add('map_center', null, [ |
|
98
|
|
|
'attr' => [ |
|
99
|
|
|
'placeholder' => 'placeholder.map_center_example', |
|
100
|
|
|
], |
|
101
|
|
|
'required' => false, |
|
102
|
|
|
'label' => 'label.settings.map_center', |
|
103
|
|
|
]) |
|
104
|
|
|
->add('map_zoom', null, [ |
|
105
|
|
|
'label' => 'label.settings.map_zoom', |
|
106
|
|
|
'constraints' => [new Range(['min' => 0, 'max' => 19])], |
|
107
|
|
|
]); |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* {@inheritdoc} |
|
112
|
|
|
*/ |
|
113
|
|
|
public function configureOptions(OptionsResolver $resolver): void |
|
114
|
|
|
{ |
|
115
|
|
|
$resolver->setDefaults([]); |
|
116
|
|
|
} |
|
117
|
|
|
} |
|
118
|
|
|
|