Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
34 / 34
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
ReferentielType
100.00% covered (success)
100.00%
34 / 34
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%
9 / 9
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;
27use Symfony\Component\Form\AbstractType;
28use Symfony\Component\Form\Extension\Core\Type\CollectionType;
29use Symfony\Component\Form\Extension\Core\Type\TextareaType;
30use Symfony\Component\Form\Extension\Core\Type\TextType;
31use Symfony\Component\Form\FormBuilderInterface;
32use Symfony\Component\OptionsResolver\OptionsResolver;
33
34class ReferentielType extends AbstractType
35{
36    /**
37     * Build type form.
38     */
39    public function buildForm(FormBuilderInterface $builder, array $options)
40    {
41        $builder
42            ->add('name', TextType::class, [
43                'label'    => 'maturity.referentiel.label.referentiel',
44                'required' => true,
45                'attr'     => [
46                    'maxlength' => 1000,
47                ],
48                'purify_html' => true,
49            ])
50            ->add('description', TextareaType::class, [
51                'label'    => 'maturity.referentiel.label.description',
52                'required' => false,
53                'attr'     => [
54                    'rows' => 3,
55                ],
56                'purify_html' => true,
57            ])
58            ->add('domains', CollectionType::class, [
59                'entry_type'     => DomainType::class,
60                'allow_add'      => true,
61                'allow_delete'   => true,
62                'by_reference'   => false,
63                'prototype_name' => '__section_name__',
64            ])
65        ;
66    }
67
68    /**
69     * Provide type options.
70     */
71    public function configureOptions(OptionsResolver $resolver)
72    {
73        $resolver
74            ->setDefaults([
75                'data_class'        => Model\Referentiel::class,
76                'validation_groups' => [
77                    'default',
78                    'referentiel',
79                ],
80            ])
81        ;
82    }
83}