如何在不覆盖它的情况下传输$ exercise参数?

Here is the function that find the first exercise with the certain 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,
    ));
}

Here I try to implement a function to al the exercises one by one

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,
    ));
}

Your problem is here:

$nextExercise= $em->getRepository('PrezentariPrezentariBundle:Exercise')->getNext($exercise);

You need to find sth.

$nextExercise= $em->getRepository('PrezentariPrezentariBundle:Exercise')->findOneById($exercise)->getNext();