mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
remove delete actions & form in controller
This commit is contained in:
parent
bebee4fbeb
commit
216d0c55be
@ -101,11 +101,8 @@ class ActivityReasonController extends Controller
|
|||||||
throw $this->createNotFoundException('Unable to find ActivityReason entity.');
|
throw $this->createNotFoundException('Unable to find ActivityReason entity.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$deleteForm = $this->createDeleteForm($id);
|
|
||||||
|
|
||||||
return $this->render('ChillActivityBundle:ActivityReason:show.html.twig', array(
|
return $this->render('ChillActivityBundle:ActivityReason:show.html.twig', array(
|
||||||
'entity' => $entity,
|
'entity' => $entity,
|
||||||
'delete_form' => $deleteForm->createView(),
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,12 +121,10 @@ class ActivityReasonController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$editForm = $this->createEditForm($entity);
|
$editForm = $this->createEditForm($entity);
|
||||||
$deleteForm = $this->createDeleteForm($id);
|
|
||||||
|
|
||||||
return $this->render('ChillActivityBundle:ActivityReason:edit.html.twig', array(
|
return $this->render('ChillActivityBundle:ActivityReason:edit.html.twig', array(
|
||||||
'entity' => $entity,
|
'entity' => $entity,
|
||||||
'edit_form' => $editForm->createView(),
|
'edit_form' => $editForm->createView()
|
||||||
'delete_form' => $deleteForm->createView(),
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,7 +160,6 @@ class ActivityReasonController extends Controller
|
|||||||
throw $this->createNotFoundException('Unable to find ActivityReason entity.');
|
throw $this->createNotFoundException('Unable to find ActivityReason entity.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$deleteForm = $this->createDeleteForm($id);
|
|
||||||
$editForm = $this->createEditForm($entity);
|
$editForm = $this->createEditForm($entity);
|
||||||
$editForm->handleRequest($request);
|
$editForm->handleRequest($request);
|
||||||
|
|
||||||
@ -177,48 +171,7 @@ class ActivityReasonController extends Controller
|
|||||||
|
|
||||||
return $this->render('ChillActivityBundle:ActivityReason:edit.html.twig', array(
|
return $this->render('ChillActivityBundle:ActivityReason:edit.html.twig', array(
|
||||||
'entity' => $entity,
|
'entity' => $entity,
|
||||||
'edit_form' => $editForm->createView(),
|
'edit_form' => $editForm->createView()
|
||||||
'delete_form' => $deleteForm->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()
|
|
||||||
;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user