Beispiel #1
0
 public function load(ObjectManager $manager)
 {
     $faker = Factory::create();
     for ($i = 1; $i <= 24; $i++) {
         $team = new Team();
         $team->setInfo($faker->text(2000));
         $country = $this->getReference("country {$i}");
         $team->setCountry($country);
         $this->setReference("team {$i}", $team);
         $manager->persist($team);
         $manager->flush();
         for ($k = 1; $k <= 11; $k++) {
             $player = new Player();
             $player->setFirstName($faker->firstNameMale);
             $player->setLastName($faker->lastName);
             $player->setBiography($faker->text(200));
             $player->setDateOfBirthday($faker->date('Y-m-d'));
             $player->setTeam($team);
             $team->getPlayers()->add($player);
             $manager->persist($player);
         }
         // the same for coaches
         for ($k = 1; $k <= 5; $k++) {
             $coach = new Coach();
             $coach->setName($faker->name);
             $coach->setBiography($faker->text(200));
             $coach->setTeam($team);
             $team->getCoaches()->add($coach);
             $manager->persist($coach);
         }
     }
     $manager->flush();
 }
 /**
  * @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');
 }
 /**
  * @Route("/admin/insert/coach/{id}", name="coach_insert_admin", requirements={"id" : "\d+"})
  *
  */
 public function generateCoachAction($id)
 {
     $teams = $this->getDoctrine()->getRepository('AppBundle:Team')->find($id);
     if (!$teams) {
         throw $this->createNotFoundException('Not found');
     }
     $faker = Factory::create();
     $em = $this->getDoctrine()->getManager();
     $coach = new Coach();
     $coach->setTeam($teams);
     $coach->setFirstName($faker->firstNameMale);
     $coach->setLastName($faker->lastName);
     $coach->setBirthDay($faker->dateTime);
     $coach->setBiography($faker->text);
     $em->persist($coach);
     $em->flush();
     $this->addFlash('notice', 'Add coach!');
     return $this->forward('AppBundle:Admin:show');
 }
 public function load(ObjectManager $manager)
 {
     $faker = \Faker\Factory::create();
     $x = 0;
     while ($x++ < 23) {
         $team = $this->getReference("team-{$x}");
         $i = 0;
         while ($i++ < 14) {
             $player = new Player();
             $player->setName($faker->firstName);
             $player->setLastName($faker->lastName);
             $player->setDescription($faker->text);
             $player->setTeam($team);
             $manager->persist($player);
             $manager->flush();
         }
         $i = 0;
         while ($i++ < 4) {
             $coach = new Coach();
             $coach->setName($faker->firstName);
             $coach->setLastName($faker->lastName);
             $coach->setDescription($faker->text);
             $coach->setTeam($team);
             $manager->persist($coach);
             $manager->flush();
         }
     }
 }
Beispiel #5
0
 public function generateCoach()
 {
     $faker = Factory::create();
     $coach = new Coach();
     $em = $this->getDoctrine()->getManager();
     for ($i = 0; $i < 10; $i++) {
         $coach->setFirstName($faker->firstNameMale);
         $coach->setLastName($faker->lastName);
         $coach->setBirthDay($faker->dateTime);
         $coach->setBiography($faker->text);
         $em->persist($coach);
     }
     $em->flush();
     $this->redirectToRoute('homepage');
 }
Beispiel #6
0
 /**
  * @param Coach $coach
  */
 public function addCoach(Coach $coach)
 {
     $coach->setTeam($this);
     $this->coaches[] = $coach;
     return $this;
 }
Beispiel #7
0
 /**
  * Add coaches
  *
  * @param \AppBundle\Entity\Coach $coach
  * @return Team
  */
 public function addCoach(\AppBundle\Entity\Coach $coach)
 {
     $this->coaches[] = $coach;
     $coach->setTeam($this);
     return $this;
 }