这是找到具有特定条件的第一个练习的功能lessonid
public function exerciseAction($lessonid, $exercise)
{
$em = $this->getDoctrine()->getEntityManager();
$exercise = $em->getRepository('PrezentariPrezentariBundle:Exercise')->findOneByLesson($lessonid);
return $this->render('PrezentariPrezentariBundle:Page:exercise.html.twig', array(
'exercise' => $exercise,
'lessonid' => $lessonid,
));
}
这里我尝试对所有的练习一一实现一个功能
public function exercisePagerAction($exercise)
{
$em = $this->getDoctrine()->getEntityManager();
$nextExercise= $em->getRepository('PrezentariPrezentariBundle:Exercise')->getNext($exercise);
return $this->render('PrezentariPrezentariBundle:Page:exercise.html.twig', array(
'exercise' => $nextExercise,
));
}