/** * Deletes a Contact entity. * * @param Contact $contact Contact * * @throws NotFoundHttpException * * @return RedirectResponse * * @Route("/contact/delete/{id}", name="contact_delete") * @ParamConverter("contact", class="AppBundle:Contact") */ public function deleteAction(Contact $contact) { if ($this->getUser() !== $contact->getUser()) { throw $this->createNotFoundException('Unable to find Contact entity.'); } $em = $this->getDoctrine()->getManager(); $em->remove($contact); $em->flush(); return $this->redirect($this->generateUrl('contact_list')); }