mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-01 20:43:49 +00:00
@@ -309,30 +309,68 @@ class ActivityController extends Controller
|
||||
'delete_form' => $deleteForm->createView(),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a Activity entity.
|
||||
*
|
||||
*/
|
||||
public function deleteAction(Request $request, $id)
|
||||
public function deleteAction(Request $request, $id, $person_id)
|
||||
{
|
||||
$form = $this->createDeleteForm($id);
|
||||
$form->handleRequest($request);
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
/* @var $activity Activity */
|
||||
$activity = $em->getRepository('ChillActivityBundle:Activity')
|
||||
->find($id);
|
||||
$person = $activity->getPerson();
|
||||
|
||||
if ($form->isValid()) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$entity = $em->getRepository('ChillActivityBundle:Activity')->find($id);
|
||||
|
||||
if (!$entity) {
|
||||
throw $this->createNotFoundException('Unable to find Activity entity.');
|
||||
}
|
||||
|
||||
$this->denyAccessUnlessGranted('CHILL_ACTIVITY_UPDATE', $entity);
|
||||
|
||||
$em->remove($entity);
|
||||
$em->flush();
|
||||
if (!$activity) {
|
||||
throw $this->createNotFoundException('Unable to find Activity entity.');
|
||||
}
|
||||
|
||||
$this->denyAccessUnlessGranted('CHILL_ACTIVITY_DELETE', $activity);
|
||||
|
||||
$form = $this->createDeleteForm($id, $person);
|
||||
|
||||
if ($request->getMethod() === Request::METHOD_DELETE) {
|
||||
$form->handleRequest($request);
|
||||
|
||||
return $this->redirect($this->generateUrl('activity'));
|
||||
if ($form->isValid()) {
|
||||
$logger = $this->get('chill.main.logger');
|
||||
|
||||
$logger->notice("An activity has been removed", array(
|
||||
'by_user' => $this->getUser()->getUsername(),
|
||||
'activity_id' => $activity->getId(),
|
||||
'person_id' => $activity->getPerson()->getId(),
|
||||
'remark' => $activity->getRemark(),
|
||||
'scope_id' => $activity->getScope()->getId(),
|
||||
'reasons_ids' => $activity->getReasons()
|
||||
->map(function ($ar) { return $ar->getId(); })
|
||||
->toArray(),
|
||||
'type_id' => $activity->getType()->getId(),
|
||||
'duration' => $activity->getDurationTime()->format('U'),
|
||||
'date' => $activity->getDate()->format('Y-m-d'),
|
||||
'attendee' => $activity->getAttendee()
|
||||
));
|
||||
|
||||
$em->remove($activity);
|
||||
$em->flush();
|
||||
|
||||
$this->addFlash('success', $this->get('translator')
|
||||
->trans("The activity has been successfully removed."));
|
||||
|
||||
return $this->redirect($this->generateUrl(
|
||||
'chill_activity_activity_list', array(
|
||||
'person_id' => $person_id
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('ChillActivityBundle:Activity:confirm_delete.html.twig', array(
|
||||
'activity' => $activity,
|
||||
'delete_form' => $form->createView()
|
||||
));
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user