/** * @Route("/classrooms/{id}/learning-card-template/create") * @Method({"GET"}) * @ParamConverter("classroom", class="AppBundle:Classroom") * * @param Request $request * @param Classroom $classroom * @return array */ public function indexAction(Request $request, Classroom $classroom) { $template = new LearningCardTemplate(); $template->addClassroom($classroom); $classroom->setLearningCardTemplate($template); $em = $this->getDoctrine()->getManager(); $em->persist($template); $em->persist($classroom); $em->flush(); return $this->redirectToRoute('app_learningcardtemplate_view_index', array('id' => $classroom->getId())); }
/** * @Given /^the classroom "([^"]*)" has an existing template$/ */ public function theClassroomHasAnExistingTemplate($classroom) { $doctrine = $this->kernel->getContainer()->get('doctrine'); $em = $doctrine->getManager(); // Get the Classroom. $classroom = $doctrine->getRepository('AppBundle:Classroom')->findOneByName($classroom); // Add a LearningCardTemplate $template = new Entity\LearningCardTemplate(); $template->addClassroom($classroom); $classroom->setLearningCardTemplate($template); $em->persist($template); $em->persist($classroom); $em->flush(); }