From 216d0c55be8c497c10d5d1ee6d26d0c0bfdfa1e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 2 Oct 2015 23:04:56 +0200 Subject: [PATCH] remove delete actions & form in controller --- Controller/ActivityReasonController.php | 51 +------------------------ 1 file changed, 2 insertions(+), 49 deletions(-) diff --git a/Controller/ActivityReasonController.php b/Controller/ActivityReasonController.php index c2093be87..1f9d3cd69 100644 --- a/Controller/ActivityReasonController.php +++ b/Controller/ActivityReasonController.php @@ -101,11 +101,8 @@ class ActivityReasonController extends Controller throw $this->createNotFoundException('Unable to find ActivityReason entity.'); } - $deleteForm = $this->createDeleteForm($id); - return $this->render('ChillActivityBundle:ActivityReason:show.html.twig', array( 'entity' => $entity, - 'delete_form' => $deleteForm->createView(), )); } @@ -124,12 +121,10 @@ class ActivityReasonController extends Controller } $editForm = $this->createEditForm($entity); - $deleteForm = $this->createDeleteForm($id); return $this->render('ChillActivityBundle:ActivityReason:edit.html.twig', array( 'entity' => $entity, - 'edit_form' => $editForm->createView(), - 'delete_form' => $deleteForm->createView(), + 'edit_form' => $editForm->createView() )); } @@ -165,7 +160,6 @@ class ActivityReasonController extends Controller throw $this->createNotFoundException('Unable to find ActivityReason entity.'); } - $deleteForm = $this->createDeleteForm($id); $editForm = $this->createEditForm($entity); $editForm->handleRequest($request); @@ -177,48 +171,7 @@ class ActivityReasonController extends Controller return $this->render('ChillActivityBundle:ActivityReason:edit.html.twig', array( 'entity' => $entity, - 'edit_form' => $editForm->createView(), - 'delete_form' => $deleteForm->createView(), + 'edit_form' => $editForm->createView() )); } - /** - * Deletes a ActivityReason entity. - * - */ - public function deleteAction(Request $request, $id) - { - $form = $this->createDeleteForm($id); - $form->handleRequest($request); - - if ($form->isValid()) { - $em = $this->getDoctrine()->getManager(); - $entity = $em->getRepository('ChillActivityBundle:ActivityReason')->find($id); - - if (!$entity) { - throw $this->createNotFoundException('Unable to find ActivityReason entity.'); - } - - $em->remove($entity); - $em->flush(); - } - - return $this->redirect($this->generateUrl('chill_activity_activityreason')); - } - - /** - * Creates a form to delete a ActivityReason entity by id. - * - * @param mixed $id The entity id - * - * @return \Symfony\Component\Form\Form The form - */ - private function createDeleteForm($id) - { - return $this->createFormBuilder() - ->setAction($this->generateUrl('chill_activity_activityreason_delete', array('id' => $id))) - ->setMethod('DELETE') - ->add('submit', 'submit', array('label' => 'Delete')) - ->getForm() - ; - } }