Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
33 / 33
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
AnswerType
100.00% covered (success)
100.00%
33 / 33
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 buildForm
100.00% covered (success)
100.00%
25 / 25
100.00% covered (success)
100.00%
1 / 1
1
 configureOptions
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3/**
4 * This file is part of the MADIS - RGPD Management application.
5 *
6 * @copyright Copyright (c) 2018-2019 Soluris - Solutions Numériques Territoriales Innovantes
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Affero General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22declare(strict_types=1);
23
24namespace App\Domain\Maturity\Form\Type;
25
26use App\Domain\Maturity\Model\Answer;
27use Symfony\Component\Form\AbstractType;
28use Symfony\Component\Form\Extension\Core\Type\HiddenType;
29use Symfony\Component\Form\Extension\Core\Type\TextType;
30use Symfony\Component\Form\FormBuilderInterface;
31use Symfony\Component\OptionsResolver\OptionsResolver;
32
33class AnswerType extends AbstractType
34{
35    /**
36     * Build type form.
37     */
38    public function buildForm(FormBuilderInterface $builder, array $options)
39    {
40        $builder
41            ->add('name', TextType::class, [
42                'label'    => 'maturity.referentiel.label.answer',
43                'required' => true,
44                'attr'     => [
45                    'maxlength' => 1000,
46                    'required'  => 'required',
47                ],
48                'purify_html' => true,
49            ])
50            ->add('recommendation', TextType::class, [
51                'label'    => 'maturity.referentiel.label.recommendation',
52                'required' => false,
53                'attr'     => [
54                    'maxlength' => 1000,
55                ],
56                'purify_html' => true,
57            ])
58            ->add('position', HiddenType::class, [
59                'required' => true,
60                'attr'     => [
61                    'class' => 'answer-position',
62                ],
63            ])
64        ;
65    }
66
67    /**
68     * Provide type options.
69     */
70    public function configureOptions(OptionsResolver $resolver)
71    {
72        $resolver
73            ->setDefaults([
74                'data_class'        => Answer::class,
75                'validation_groups' => [
76                    'default',
77                    'answer',
78                ],
79            ]);
80    }
81}