/** * @Route("/bidevaluation/{id}/remove", name="bidevaluation_removal") * @Template() * @Security("has_role('ROLE_CONTRACTING')") */ public function bidEvaluationRemoveAction($id) { $em = $this->getDoctrine()->getManager(); $bidevaluation = $em->getRepository('AppBundle:BidEvaluation')->findOneBy(array('id' => $id)); if (!$bidevaluation) { throw $this->createNotFoundException('No record found for bid evaluation with id' . $id); } $em->remove($bidevaluation); $em->flush(); //Audit $audit = new Audit(); $user = $this->get('security.token_storage')->getToken()->getUser(); $audit->setUsername($user->getUsername()); $audit->setName($user->getFirstname() . " " . $user->getLastname()); $audit->setFunctionType("Contracting"); $audit->setEventType("Delete tender evaluation"); $audit->setDossier($bidevaluation->getBid()->getContract()); $em->persist($audit); $em->flush(); return $this->redirect($this->generateUrl('contracting_view_tenders', array('id' => $bidevaluation->getBid()->getContract()->getId()))); }