/** * Edits an existing InteractionMatching entity. * * @access public * * @param integer $id id of InteractionMatching * * @return \Symfony\Component\HttpFoundation\Response */ public function updateAction($id) { $exoID = $this->container->get('request')->request->get('exercise'); $user = $this->container->get('security.token_storage')->getToken()->getUser(); $catID = -1; $em = $this->getdoctrine()->getManager(); $interMatching = $em->getRepository('UJMExoBundle:InteractionMatching')->find($id); if (!$interMatching) { throw $this->createNotFoundException('Enable to find InteractionMatching entity.'); } if ($user->getId() != $interMatching->getInteraction()->getQuestion()->getUser()->getId()) { $catID = $interMatching->getInteraction()->getQuestion()->getUser()->getId(); } $editForm = $this->createForm(new InteractionMatchingType($this->container->get('security.token_storage')->getToken()->getUser(), $catID), $interMatching); $formHandler = new InteractionMatchingHandler($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($interMatching)) { 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' => $interMatching->getInteraction()->getQuestion()->getId(), 'form' => $editForm)); }