Projekt

Obecné

Profil

Stáhnout (2.28 KB) Statistiky
| Větev: | Revize:
1 2f227a6c ballakt
<?php
2
3
namespace App\Form;
4
5
use App\Utils\Utils;
6
use App\Entity\DataSet;
7
use Symfony\Component\Form\Forms;
8
use App\Repository\IOpenDataManager;
9
use Symfony\Component\Form\Extension\Core\Type\FormType;
10
use Symfony\Component\Form\Extension\Core\Type\TextType;
11
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
12
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
13
14
class DatasetFormBuilder {
15
    /**
16
     * @var IOpenDataManager autowired connection to database
17
     */
18
    private $manager;
19
20
    /**
21
     * @param IOpenDataManager autowired connection to database
22
     */
23
    public function __construct(IOpenDataManager $manager) {
24
        $this->manager = $manager;
25
    }
26
27
    public function getBuilder() {
28
        $dataSet = new DataSet();
29
30
        return Forms::createFormFactoryBuilder()->getFormFactory()->createNamedBuilder('', FormType::class, $dataSet)
31
            ->add('date', TextType::class)
32
            ->add('time', ChoiceType::class, [
33
                'choices' => [
34
                    '0:00-1:00' => 0,
35
                    '1:00-2:00' => 1,
36
                    '2:00-3:00' => 2,
37
                    '3:00-4:00' => 3,
38
                    '4:00-5:00' => 4,
39
                    '5:00-6:00' => 5,
40
                    '6:00-7:00' => 6,
41
                    '7:00-8:00' => 7,
42
                    '8:00-9:00' => 8,
43
                    '9:00-10:00' => 9,
44
                    '10:00-11:00' => 10,
45
                    '11:00-12:00' => 11,
46
                    '12:00-13:00' => 12,
47
                    '13:00-14:00' => 13,
48
                    '14:00-15:00' => 14,
49
                    '15:00-16:00' => 15,
50
                    '16:00-17:00' => 16,
51
                    '17:00-18:00' => 17,
52
                    '18:00-19:00' => 18,
53
                    '19:00-20:00' => 19,
54
                    '20:00-21:00' => 20,
55
                    '21:00-22:00' => 21,
56
                    '22:00-23:00' => 22,
57
                    '23:00-0:00' => 23,
58
                ],
59 1cf1413d ballakt
                'multiple' => false,
60
                'expanded' => true,
61 2f227a6c ballakt
            ])->add('type', ChoiceType::class, [
62
                'choices' => Utils::prepareDatasetsNames($this->manager->getAvailableCollections()),
63
                'multiple' => true,
64
                'expanded' => true,
65
            ])
66
            ->add('submit', SubmitType::class);
67
    }
68
}