Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
56 / 56 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| StoreType | |
100.00% |
56 / 56 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| buildForm | |
100.00% |
56 / 56 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace App\Form; |
| 6 | |
| 7 | use App\Entity\User; |
| 8 | use Doctrine\ORM\EntityRepository; |
| 9 | use Doctrine\ORM\QueryBuilder; |
| 10 | use Override; |
| 11 | use Symfony\Bridge\Doctrine\Form\Type\EntityType; |
| 12 | use Symfony\Component\Form\AbstractType; |
| 13 | use Symfony\Component\Form\FormBuilderInterface; |
| 14 | |
| 15 | class StoreType extends AbstractType |
| 16 | { |
| 17 | #[Override] |
| 18 | public function buildForm( |
| 19 | FormBuilderInterface $builder, |
| 20 | array $options |
| 21 | ): void |
| 22 | { |
| 23 | $builder |
| 24 | ->add( |
| 25 | 'user', |
| 26 | EntityType::class, |
| 27 | [ |
| 28 | 'class' => User::class, |
| 29 | 'choice_label' => 'name', |
| 30 | 'placeholder' => '-Desocupado-', |
| 31 | 'required' => false, |
| 32 | 'label' => 'Inquilino', |
| 33 | 'query_builder' => static fn( |
| 34 | EntityRepository $er |
| 35 | ): QueryBuilder => $er->createQueryBuilder('u') |
| 36 | ->where('u.role = :role') |
| 37 | ->andWhere('u.isActive = :state') |
| 38 | ->setParameter('role', User::ROLES['user']) |
| 39 | ->setParameter('state', true) |
| 40 | ->orderBy('u.name'), |
| 41 | ] |
| 42 | ) |
| 43 | ->add('destination', null, [ |
| 44 | 'label' => 'Destino', |
| 45 | ]) |
| 46 | ->add('valAlq', null, [ |
| 47 | 'label' => 'Alquiler', |
| 48 | ]) |
| 49 | ->add('cntLanfort', null, [ |
| 50 | 'label' => 'Lanfort', |
| 51 | ]) |
| 52 | ->add('cntNeon', null, [ |
| 53 | 'label' => 'Neon', |
| 54 | ]) |
| 55 | ->add('cntSwitch', null, [ |
| 56 | 'label' => 'Switch', |
| 57 | ]) |
| 58 | ->add('cntToma', null, [ |
| 59 | 'label' => 'Toma', |
| 60 | ]) |
| 61 | ->add('cntVentana', null, [ |
| 62 | 'label' => 'Ventana', |
| 63 | ]) |
| 64 | ->add('cntLlaves', null, [ |
| 65 | 'label' => 'Llaves', |
| 66 | ]) |
| 67 | ->add('cntMedElec', null, [ |
| 68 | 'label' => 'Medidor', |
| 69 | ]) |
| 70 | ->add('cntMedAgua', null, [ |
| 71 | 'label' => 'Medidor', |
| 72 | ]) |
| 73 | ->add('medElectrico', null, [ |
| 74 | 'label' => 'Electrico', |
| 75 | ]) |
| 76 | ->add('medAgua', null, [ |
| 77 | 'label' => 'Agua', |
| 78 | ]); |
| 79 | } |
| 80 | } |