1
|
<?php
|
2
|
|
3
|
namespace App\Form;
|
4
|
|
5
|
use App\Utils\Utils;
|
6
|
use App\Entity\DataSet;
|
7
|
use App\Repository\IOpenDataManager;
|
8
|
use Symfony\Component\Form\FormView;
|
9
|
use Symfony\Component\Form\AbstractType;
|
10
|
use Symfony\Component\Form\FormInterface;
|
11
|
use Symfony\Component\Form\FormBuilderInterface;
|
12
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
13
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
14
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
15
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
16
|
|
17
|
class DataSetType extends AbstractType {
|
18
|
private $manager;
|
19
|
|
20
|
public function __construct(IOpenDataManager $manager) {
|
21
|
$this->manager = $manager;
|
22
|
}
|
23
|
|
24
|
public function buildForm(FormBuilderInterface $builder, array $options) {
|
25
|
$builder
|
26
|
->add('date', TextType::class)
|
27
|
->add('time', ChoiceType::class, [
|
28
|
'choices' => [
|
29
|
'0:00-1:00' => 0,
|
30
|
'1:00-2:00' => 1,
|
31
|
'2:00-3:00' => 2,
|
32
|
'3:00-4:00' => 3,
|
33
|
'4:00-5:00' => 4,
|
34
|
'5:00-6:00' => 5,
|
35
|
'6:00-7:00' => 6,
|
36
|
'7:00-8:00' => 7,
|
37
|
'8:00-9:00' => 8,
|
38
|
'9:00-10:00' => 9,
|
39
|
'10:00-11:00' => 10,
|
40
|
'11:00-12:00' => 11,
|
41
|
'12:00-13:00' => 12,
|
42
|
'13:00-14:00' => 13,
|
43
|
'14:00-15:00' => 14,
|
44
|
'15:00-16:00' => 15,
|
45
|
'16:00-17:00' => 16,
|
46
|
'17:00-18:00' => 17,
|
47
|
'18:00-19:00' => 18,
|
48
|
'19:00-20:00' => 19,
|
49
|
'20:00-21:00' => 20,
|
50
|
'21:00-22:00' => 21,
|
51
|
'22:00-23:00' => 22,
|
52
|
'23:00-0:00' => 23,
|
53
|
],
|
54
|
])
|
55
|
->add('type', ChoiceType::class, [
|
56
|
'choices' => Utils::prepareDatasetsNames($this->manager->getAvailableCollections()),
|
57
|
])
|
58
|
->add('submit', SubmitType::class);
|
59
|
}
|
60
|
|
61
|
public function configureOptions(OptionsResolver $resolver) {
|
62
|
$resolver->setDefaults([
|
63
|
'data_class' => DataSet::class,
|
64
|
'method' => 'GET',
|
65
|
]);
|
66
|
}
|
67
|
|
68
|
// public function buildView(FormView $view, Forminterface $form, array $options) {
|
69
|
|
70
|
// }
|
71
|
}
|