Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 40 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
AnalyseCriterePrincipeFondamentalType | |
0.00% |
0 / 40 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
buildForm | |
0.00% |
0 / 31 |
|
0.00% |
0 / 1 |
2 | |||
configureOptions | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace App\Domain\AIPD\Form\Type; |
6 | |
7 | use App\Domain\AIPD\Model\CriterePrincipeFondamental; |
8 | use Knp\DictionaryBundle\Form\Type\DictionaryType; |
9 | use Symfony\Component\Form\AbstractType; |
10 | use Symfony\Component\Form\Extension\Core\Type\FileType; |
11 | use Symfony\Component\Form\Extension\Core\Type\TextareaType; |
12 | use Symfony\Component\Form\FormBuilderInterface; |
13 | use Symfony\Component\OptionsResolver\OptionsResolver; |
14 | use Symfony\Component\Validator\Constraints\File; |
15 | |
16 | class AnalyseCriterePrincipeFondamentalType extends AbstractType |
17 | { |
18 | protected string $maxSize; |
19 | |
20 | public function __construct(string $maxSize) |
21 | { |
22 | $this->maxSize = $maxSize; |
23 | } |
24 | |
25 | public function buildForm(FormBuilderInterface $builder, array $options) |
26 | { |
27 | $builder->add('reponse', DictionaryType::class, [ |
28 | 'name' => 'reponse_critere_fondamental', |
29 | ]) |
30 | ->add('justification', TextareaType::class, [ |
31 | 'required' => false, |
32 | 'attr' => [ |
33 | 'maxlength' => 2000, |
34 | 'rows' => 1, |
35 | 'class' => 'textareaheight', |
36 | ], |
37 | 'purify_html' => true, |
38 | ]) |
39 | ->add('fichierFile', FileType::class, [ |
40 | 'required' => false, |
41 | 'label' => false, |
42 | 'attr' => [ |
43 | 'accept' => 'image/*', |
44 | ], |
45 | 'constraints' => [ |
46 | new File([ |
47 | 'maxSize' => $this->maxSize, |
48 | 'groups' => ['default'], |
49 | 'mimeTypes' => [ |
50 | 'image/png', // .png |
51 | 'image/jpeg', // .jpg, .jpeg |
52 | ], |
53 | 'mimeTypesMessage' => 'aipd_validator.fichier.file', |
54 | ]), |
55 | ], |
56 | ]) |
57 | ; |
58 | } |
59 | |
60 | public function configureOptions(OptionsResolver $resolver) |
61 | { |
62 | $resolver |
63 | ->setDefaults([ |
64 | 'data_class' => CriterePrincipeFondamental::class, |
65 | 'validation_groups' => [ |
66 | 'default', |
67 | 'critere', |
68 | ], |
69 | ]); |
70 | } |
71 | } |