From 34748dca76fccbfc534881bb1edcc4700e3b7e72 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 29 Oct 2024 15:55:25 +0100 Subject: [PATCH] Create a gender fixture --- .../DataFixtures/ORM/LoadGenders.php | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadGenders.php diff --git a/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadGenders.php b/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadGenders.php new file mode 100644 index 000000000..bbc9c1a3f --- /dev/null +++ b/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadGenders.php @@ -0,0 +1,63 @@ + ['en' => 'man', 'fr' => 'homme'], + 'genderTranslation' => GenderEnum::MALE, + 'icon' => GenderIconEnum::MALE + ], + [ + 'label' => ['en' => 'woman', 'fr' => 'femme'], + 'genderTranslation' => GenderEnum::FEMALE, + 'icon' => GenderIconEnum::FEMALE + ], + [ + 'label' => ['en' => 'neutral', 'fr' => 'neutre'], + 'genderTranslation' => GenderEnum::NEUTRAL, + 'icon' => GenderIconEnum::NEUTRAL + ], + ]; + + public function getOrder() + { + return 100; + } + + public function load(ObjectManager $manager) + { + echo "loading genders... \n"; + + foreach ($this->genders as $g) { + echo $g['label']['fr'].' '; + $new_g = new Gender(); + $new_g->setGenderTranslation($g['genderTranslation']); + $new_g->setLabel($g['label']); + $new_g->setIcon($g['icon']); + + $this->addReference('g_'.$g['genderTranslation'], $new_g); + $manager->persist($new_g); + } + + $manager->flush(); + } +}