Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 70a3df53

Přidáno uživatelem Jakub Vašta před asi 4 roky(ů)

+ Re #8086
+ php refactoring and comments

Zobrazit rozdíly:

website/src/Form/DataSetType.php
5 5
use App\Utils\Utils;
6 6
use App\Entity\DataSet;
7 7
use App\Repository\IOpenDataManager;
8
use Symfony\Component\Form\FormView;
9 8
use Symfony\Component\Form\AbstractType;
10
use Symfony\Component\Form\FormInterface;
11 9
use Symfony\Component\Form\FormBuilderInterface;
12 10
use Symfony\Component\OptionsResolver\OptionsResolver;
13 11
use Symfony\Component\Form\Extension\Core\Type\TextType;
......
15 13
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
16 14

  
17 15
class DataSetType extends AbstractType {
16
    /**
17
     * @var IOpenDataManager autowired connection to database
18
     */
18 19
    private $manager;
19 20

  
21
    /**
22
     * @param IOpenDataManager autowired connection to database
23
     */
20 24
    public function __construct(IOpenDataManager $manager) {
21 25
        $this->manager = $manager;
22 26
    }
23 27

  
28
    /**
29
     * @see https://symfony.com/doc/current/forms.html
30
     */
24 31
    public function buildForm(FormBuilderInterface $builder, array $options) {
25 32
        $builder
26 33
            ->add('date', TextType::class)
34
            // Populate time select with data
27 35
            ->add('time', ChoiceType::class, [
28 36
                'choices' => [
29 37
                    '0:00-1:00' => 0,
......
52 60
                    '23:00-0:00' => 23,
53 61
                ],
54 62
            ])
63
            // Populet type select with data
55 64
            ->add('type', ChoiceType::class, [
56 65
                'choices' => Utils::prepareDatasetsNames($this->manager->getAvailableCollections()),
57 66
            ])
58 67
            ->add('submit', SubmitType::class);
59 68
    }
60 69

  
70
    /**
71
     * @see https://symfony.com/doc/current/forms.html
72
     */
61 73
    public function configureOptions(OptionsResolver $resolver) {
62 74
        $resolver->setDefaults([
63 75
            'data_class' => DataSet::class,
64 76
            'method' => 'GET',
65 77
        ]);
66 78
    }
67

  
68
    // public function buildView(FormView $view, Forminterface $form, array $options) {
69

  
70
    // }
71 79
}

Také k dispozici: Unified diff