/** * @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'); }