/**
  * Edits an existing InteractionOpen entity.
  *
  * @access public
  *
  * @param integer $id id of InteractionOpen
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function updateAction($id)
 {
     $user = $this->container->get('security.token_storage')->getToken()->getUser();
     $exoID = $this->container->get('request')->request->get('exercise');
     $catID = -1;
     $em = $this->getDoctrine()->getManager();
     $interOpen = $em->getRepository('UJMExoBundle:InteractionOpen')->find($id);
     if (!$interOpen) {
         throw $this->createNotFoundException('Unable to find InteractionOpen entity.');
     }
     if ($user->getId() != $interOpen->getInteraction()->getQuestion()->getUser()->getId()) {
         $catID = $interOpen->getInteraction()->getQuestion()->getCategory()->getId();
     }
     $editForm = $this->createForm(new InteractionOpenType($this->container->get('security.token_storage')->getToken()->getUser(), $catID), $interOpen);
     $formHandler = new InteractionOpenHandler($editForm, $this->get('request'), $this->getDoctrine()->getManager(), $this->container->get('ujm.exercise_services'), $this->container->get('security.token_storage')->getToken()->getUser(), $this->get('translator'));
     if ($formHandler->processUpdate($interOpen)) {
         if ($exoID == -1) {
             return $this->redirect($this->generateUrl('ujm_question_index'));
         } else {
             return $this->redirect($this->generateUrl('ujm_exercise_questions', array('id' => $exoID)));
         }
     }
     return $this->forward('UJMExoBundle:Question:edit', array('exoID' => $exoID, 'id' => $interOpen->getInteraction()->getQuestion()->getId(), 'form' => $editForm));
 }