added delete timesheet records action for users #67 (#72)

This commit is contained in:
Kevin Papst
2018-01-09 21:47:32 +01:00
committed by GitHub
parent 03896e3a1a
commit 42bf4f41f7
6 changed files with 39 additions and 6 deletions

View File

@@ -144,6 +144,26 @@ class TimesheetController extends AbstractController
return $this->create($request, 'timesheet', 'TimesheetBundle:timesheet:edit.html.twig');
}
/**
* The route to delete an existing entry.
*
* @Route("/{id}/delete", name="timesheet_delete")
* @Method({"GET", "POST"})
* @Security("is_granted('delete', entry)")
*
* @param Timesheet $entry
* @param Request $request
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
*/
public function deleteAction(Timesheet $entry, Request $request)
{
$entityManager = $this->getDoctrine()->getManager();
$entityManager->remove($entry);
$entityManager->flush();
return $this->redirectToRoute('timesheet_paginated', ['page' => $request->get('page')]);
}
/**
* @param Timesheet $entry
* @return \Symfony\Component\Form\FormInterface