Exemplo n.º 1
0
 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');
 }
Exemplo n.º 2
0
 /**
  * @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');
 }