Skip to content

Commit

Permalink
784 : change fixtures to add declarants on some signalements
Browse files Browse the repository at this point in the history
  • Loading branch information
hmeneuvrier committed Jan 30, 2023
1 parent bc65b75 commit aae6271
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
3 changes: 3 additions & 0 deletions src/DataFixtures/Files/Signalement.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ signalements:
uuid: "00000000-0000-0000-2022-000000000001"
details: "Absence d’isolation toiture<br><br>Courrier adressé non pas à la mairie mais au bailleur social"
is_proprio_averti: 1
is_not_occupant: true
nb_adultes: "2"
is_allocataire: "CAF"
nature_logement: "Appartement"
Expand Down Expand Up @@ -127,6 +128,7 @@ signalements:
uuid: "00000000-0000-0000-2022-000000000004"
details: "appartement insalubre avec des..."
is_proprio_averti: 1
is_not_occupant: true
nb_adultes: "2"
is_allocataire: ""
nature_logement: "Appartement"
Expand Down Expand Up @@ -541,6 +543,7 @@ signalements:
uuid: "00000000-0000-0000-2022-000000000014"
details: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
is_proprio_averti: 1
is_not_occupant: true
nb_adultes: "3"
is_allocataire: "CAF"
nature_logement: "Appartement"
Expand Down
12 changes: 12 additions & 0 deletions src/DataFixtures/Loader/LoadSignalementData.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Entity\Signalement;
use App\Entity\User;
use App\Form\SignalementType;
use App\Repository\CritereRepository;
use App\Repository\CriticiteRepository;
use App\Repository\SituationRepository;
Expand Down Expand Up @@ -88,6 +89,17 @@ private function loadSignalements(ObjectManager $manager, array $row)
->setOrigineSignalement($row['origine_signalement'])
->setCreatedAt((new \DateTimeImmutable())->modify('-15 days'));

if (isset($row['is_not_occupant'])) {
$signalement
->setIsNotOccupant($row['is_not_occupant'])
->setNomDeclarant($faker->lastName())
->setPrenomDeclarant($faker->firstName())
->setTelDeclarant($phoneNumber)
->setMailDeclarant($faker->email())
->setStructureDeclarant($faker->company())
->setLienDeclarantOccupant(SignalementType::LINK_CHOICES[array_rand(SignalementType::LINK_CHOICES)]);
}

if (isset($row['is_imported'])) {
$signalement
->setIsImported($row['is_imported'])
Expand Down
16 changes: 9 additions & 7 deletions src/Form/SignalementType.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@

class SignalementType extends AbstractType
{
public const LINK_CHOICES = [
'Proche' => 'PROCHE',
'Professionnel' => 'PROFESSIONNEL',
'Tuteur / Tutrice' => 'TUTEUR',
'Voisin / Voisine' => 'VOISIN',
'Autre' => 'AUTRE',
];

public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
Expand Down Expand Up @@ -543,13 +551,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'required' => false,
])
->add('lienDeclarantOccupant', ChoiceType::class, [
'choices' => [
'Proche' => 'PROCHE',
'Professionnel' => 'PROFESSIONNEL',
'Tuteur / Tutrice' => 'TUTEUR',
'Voisin / Voisine' => 'VOISIN',
'Autre' => 'AUTRE',
],
'choices' => self::LINK_CHOICES,
'expanded' => true,
'label_attr' => [
'class' => 'fr-label',
Expand Down

0 comments on commit aae6271

Please sign in to comment.