/** * @Given /^there are the following classrooms:$/ */ public function thereAreTheFollowingClassrooms(TableNode $table) { $em = $this->kernel->getContainer()->get('doctrine')->getManager(); foreach ($table->getHash() as $hash) { $classroom = new Entity\Classroom(); $classroom->setName($hash['name']); $classroom->setTeacher($this->findTeacherEntity($hash['teacher'])); $em->persist($classroom); $em->flush(); } }
/** * @Route("/classrooms/view/{id}/learning-card-template") * @Method({"GET", "POST"}) * @Template("LearningCardTemplate\View\index.html.twig") * @ParamConverter("classroom", class="AppBundle:Classroom") * * @param Request $request * @param Classroom $classroom * @return array */ public function indexAction(Request $request, Classroom $classroom) { $template = $classroom->getLearningCardTemplate(); $form = $this->createForm(new LearningCardTemplateType(), $template); $form->handleRequest($request); if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); $template = $form->getData(); $em->persist($template); $em->flush(); } return array('classroom' => $classroom, 'form' => $form->createView()); }