Ejemplo n.º 1
0
 /**
  * @Route("/generate", name="fakeEntityGenerator")
  * @Method("GET")
  */
 public function generateAction()
 {
     $faker = Factory::create();
     $em = $this->getDoctrine()->getManager();
     foreach ($this->countryNames as $countryName) {
         $country = new Country();
         $country->setName($countryName);
         $country->setFlag($countryName . '.png');
         $country->setDescription($faker->text(3000));
         $team = new Team();
         $team->setName($countryName);
         $team->setDescription($faker->text(3000));
         $team->setCountry($country);
         for ($i = 0; $i < 16; $i++) {
             $player = new Player();
             $player->setName($faker->name);
             $player->setDescription($faker->text(3000));
             $player->setTeam($team);
             $em->persist($player);
         }
         for ($i = 0; $i < 4; $i++) {
             $coach = new Coach();
             $coach->setName($faker->name);
             $coach->setDescription($faker->text(3000));
             $coach->setTeam($team);
             $em->persist($coach);
         }
         $em->persist($country);
         $em->persist($team);
     }
     $em->flush();
     return $this->redirectToRoute('homePage');
 }
Ejemplo n.º 2
0
 public function load(ObjectManager $manager)
 {
     $faker = \Faker\Factory::create();
     $x = 0;
     while ($x++ < 25) {
         $country = $this->getReference("country-{$x}");
         $team = new Team();
         $team->setDescription($faker->text);
         $team->setCountry($country);
         $manager->persist($team);
         $manager->flush();
         $this->addReference("team-{$x}", $team);
     }
 }