Lines
100.00%
23 / 23
Functions and Methods
100.00%
2 / 2
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| TimelineEventType | 100.00% | 23 / 23 | 100.00% | 2 / 2 | 2 | 100.00% | 1 / 1 | |||
| buildForm | 100.00% | 20 / 20 | 100.00% | 1 / 1 | 1 | |||||
| configureOptions | 100.00% | 3 / 3 | 100.00% | 1 / 1 | 1 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace App\Form; | |
| 6 | ||
| 7 | use App\Entity\TimelineEvent; | |
| 8 | use Symfony\Component\Form\AbstractType; | |
| 9 | use Symfony\Component\Form\Extension\Core\Type\DateType; | |
| 10 | use Symfony\Component\Form\Extension\Core\Type\TextareaType; | |
| 11 | use Symfony\Component\Form\FormBuilderInterface; | |
| 12 | use Symfony\Component\OptionsResolver\OptionsResolver; | |
| 13 | ||
| 14 | /** | |
| 15 | * A custom event on the timeline: on /agent-stats (new) and its edit page. | |
| 16 | */ | |
| 17 | class TimelineEventType extends AbstractType | |
| 18 | { | |
| 19 | public function buildForm(FormBuilderInterface $builder, array $options): void | |
| 20 | { | |
| 21 | $builder | |
| 22 | ->add('date', DateType::class, [ | |
| 23 | 'label' => 'timeline.event.date', | |
| 24 | 'widget' => 'single_text', | |
| 25 | 'input' => 'datetime_immutable', | |
| 26 | ]) | |
| 27 | ->add('endDate', DateType::class, [ | |
| 28 | 'label' => 'timeline.event.end_date', | |
| 29 | 'help' => 'timeline.event.end_date_help', | |
| 30 | 'widget' => 'single_text', | |
| 31 | 'input' => 'datetime_immutable', | |
| 32 | 'required' => false, | |
| 33 | ]) | |
| 34 | ->add('text', TextareaType::class, [ | |
| 35 | 'label' => 'timeline.event.text', | |
| 36 | // Blank is null otherwise, the entity's text is a string | |
| 37 | 'empty_data' => '', | |
| 38 | 'help' => 'timeline.event.text_help', | |
| 39 | 'attr' => ['maxlength' => 500, 'rows' => 2], | |
| 40 | ]) | |
| 41 | ; | |
| 42 | } | |
| 43 | ||
| 44 | public function configureOptions(OptionsResolver $resolver): void | |
| 45 | { | |
| 46 | $resolver->setDefaults([ | |
| 47 | 'data_class' => TimelineEvent::class, | |
| 48 | ]); | |
| 49 | } | |
| 50 | } |