コード例 #1
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $this->manager = $manager;
     $this->nationalities = $manager->getRepository('BuddySystemMembersBundle:Nationality')->findAll();
     $this->universities = $manager->getRepository('BuddySystemMembersBundle:Univercity')->findAll();
     $maxNationalitiesId = $this->getMaxId('BuddySystemMembersBundle:Nationality');
     $maxUniversitiesId = $this->getMaxId('BuddySystemMembersBundle:Univercity');
     //Create local Members
     for ($i = 0; $i < 20; $i++) {
         $user = new User();
         $user->setEnabled(true);
         $user->setDob($this->getRandomDatetime());
         $user->setArrival($this->getRandomArrival());
         $user->setDepart($this->getRandomDepart());
         $nationality = $this->getFrenchNationality();
         $nationality->addUser($user);
         $user->setNationaliteVoulu($manager->getRepository('BuddySystemMembersBundle:Nationality')->findOneBy(array("id" => rand($maxNationalitiesId - count($this->nationalities) + 1, $maxNationalitiesId))));
         $name = $this->getRandomName();
         $user->setUsername($name);
         $user->setNom($name);
         $user->setPrenom($this->getRandomSurname());
         $user->setEmail($this->getRandomEmail());
         $university = $manager->getRepository('BuddySystemMembersBundle:Univercity')->findOneBy(array("id" => rand($maxUniversitiesId - count($this->universities) + 1, $maxUniversitiesId)));
         $university->addUser($user);
         $user->setTel($this->getRandomPhoneNumber());
         $user->setPlainPassword("fixtures");
         $user->setSexe($this->sexes[rand(0, 1)]);
         $user->setSexewanted($this->sexes[rand(0, 1)]);
         $user->setConditionGenerale(true);
         $user->setNationalityOsef(true);
         $user->setSection($this->manager->getRepository('BuddySystemMainBundle:Section')->findOneBy(array("code_section" => "FR-LILL-ESL")));
         $manager->persist($user);
         $manager->flush();
     }
     //Create IS Members
     for ($i = 0; $i < 20; $i++) {
         $user = new User();
         $user->setEnabled(true);
         $user->setDob($this->getRandomDatetime());
         $user->setArrival($this->getRandomArrival());
         $user->setDepart($this->getRandomDepart());
         $nationality = $manager->getRepository('BuddySystemMembersBundle:Nationality')->findOneBy(array("id" => rand($maxNationalitiesId - count($this->nationalities) + 1, $maxNationalitiesId)));
         $nationality->addUser($user);
         $name = $this->getRandomName();
         $user->setUsername($name);
         $user->setNom($name);
         $user->setPrenom($this->getRandomSurname());
         $user->setEmail($this->getRandomEmail());
         $university = $manager->getRepository('BuddySystemMembersBundle:Univercity')->findOneBy(array("id" => rand($maxUniversitiesId - count($this->universities) + 1, $maxUniversitiesId)));
         $university->addUser($user);
         $user->setTel($this->getRandomPhoneNumber());
         $user->setPlainPassword("fixtures");
         $user->setSexe($this->sexes[rand(0, 1)]);
         $user->setSexewanted($this->sexes[rand(0, 1)]);
         $user->setConditionGenerale(true);
         $user->setNationalityOsef(false);
         $user->setNationaliteVoulu($this->getFrenchNationality());
         $user->setSection($this->manager->getRepository('BuddySystemMainBundle:Section')->findOneBy(array("code_section" => "FR-LILL-ESL")));
         $manager->persist($user);
         $manager->flush();
     }
 }