/** * @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'); }
public function generateCountry() { $faker = Factory::create(); $country = new Country(); $em = $this->getDoctrine()->getManager(); for ($i = 0; $i < 10; $i++) { $country->setFullTitle($faker->country); $country->setDescription($faker->text); $em->persist($country); } $em->flush(); $this->redirectToRoute('homepage'); }
/** * @Route("/admin/insert/country/{id}", name="country_insert_admin", requirements={"id" : "\d+"}) * */ public function generateCountryAction($id) { $teams = $this->getDoctrine()->getRepository('AppBundle:Team')->find($id); if (!$teams) { throw $this->createNotFoundException('Not found'); } $faker = Factory::create(); $em = $this->getDoctrine()->getManager(); $country = new Country(); $country->setTeam($teams); $country->setFullTitle($faker->country); $country->setDescription($faker->text); $em->persist($country); $em->flush(); $this->addFlash('notice', 'Add country!'); return $this->forward('AppBundle:Admin:show'); }
public function load(ObjectManager $manager) { $faker = \Faker\Factory::create(); $x = 0; while ($x++ < 25) { $contryname = $faker->country($x); $slug = str_replace(' ', '-', $contryname); $slug = preg_replace('/[^A-Za-z\\-]/', '', $slug); $country = new Country(); $country->setName($contryname); $country->setSlug(strtolower($slug)); $country->setDescription($faker->text); $country->setImage($faker->imageUrl(22, 15)); $manager->persist($country); $manager->flush(); $this->addReference("country-{$x}", $country); } }
public function load(ObjectManager $manager) { $faker = \Faker\Factory::create(); $countries = ['France', 'England', 'Czech Republic', 'Iceland', 'Austria', 'Northern Ireland', 'Portugal', 'Spain', 'Switzerland', 'Italy', 'Belgium', 'Wales', 'Romania', 'Albania', 'Germany', 'Poland', 'Russia', ' Slovakia', 'Croatia', 'Turkey', 'Hungary', 'Republic of Ireland', 'Sweden', 'Ukraine']; $x = -1; foreach ($countries as $x => $value) { $contryname = $value; $slug = str_replace(' ', '-', $contryname); $slug = preg_replace('/[^A-Za-z\\-]/', '', $slug); $country = new Country(); $country->setName($contryname); $country->setSlug(strtolower($slug)); $country->setDescription($faker->text); $country->setImage($faker->imageUrl(22, 15)); $manager->persist($country); $manager->flush(); $this->addReference("country-{$x}", $country); } }