added delete timesheet record for admins #70 (#73)

This commit is contained in:
Kevin Papst
2018-01-09 21:59:32 +01:00
committed by GitHub
parent 42bf4f41f7
commit 098a1325d6
3 changed files with 30 additions and 6 deletions

View File

@@ -108,6 +108,26 @@ class TimesheetController extends AbstractController
return $this->create($request, 'admin_timesheet', 'TimesheetBundle:admin:timesheet_edit.html.twig');
}
/**
* The route to delete an existing entry.
*
* @Route("/{id}/delete", name="admin_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('admin_timesheet_paginated', ['page' => $request->get('page')]);
}
/**
* @param Timesheet $entry
* @return \Symfony\Component\Form\FormInterface