diff --git a/src/Hackspace/Bundle/CalciferBundle/Controller/RepeatingEventController.php b/src/Hackspace/Bundle/CalciferBundle/Controller/RepeatingEventController.php index db41dca..91f5b65 100755 --- a/src/Hackspace/Bundle/CalciferBundle/Controller/RepeatingEventController.php +++ b/src/Hackspace/Bundle/CalciferBundle/Controller/RepeatingEventController.php @@ -257,6 +257,42 @@ class RepeatingEventController extends Controller $em->flush(); return $entity; + } + /** + * Deletes a Event entity. + * + * @Route("/{slug}/löschen", name="repeating_event_delete") + * @Method({"GET", "POST"}) + * @Template("CalciferBundle:RepeatingEvent:delete.html.twig") + */ + public function deleteAction(Request $request, $slug) { + /** @var EntityManager $em */ + $em = $this->getDoctrine()->getManager(); + + /** @var EntityRepository $repo */ + $repo = $em->getRepository('CalciferBundle:RepeatingEvent'); + + /** @var Event $entity */ + $entity = $repo->findOneBy(['slug' => $slug]); + + if (!$entity) { + throw $this->createNotFoundException('Unable to find Event entity.'); + } + + + $confirmation = $request->get('confirmation',false); + + if (($request->getMethod() == 'POST') && ($confirmation)) { + $em->remove($entity); + $em->flush(); + + return $this->redirect('/'); + } + + return array( + 'entity' => $entity, + + ); } } diff --git a/src/Hackspace/Bundle/CalciferBundle/Resources/views/RepeatingEvent/delete.html.twig b/src/Hackspace/Bundle/CalciferBundle/Resources/views/RepeatingEvent/delete.html.twig new file mode 100755 index 0000000..26d8f37 --- /dev/null +++ b/src/Hackspace/Bundle/CalciferBundle/Resources/views/RepeatingEvent/delete.html.twig @@ -0,0 +1,29 @@ +{% extends 'CalciferBundle::layout.html.twig' %} + +{% block css %} + {% stylesheets filter="compass" + "@CalciferBundle/Resources/assets/css/events.scss" %} + + {% endstylesheets %} +{% endblock %} + +{% block javascripts %} + {% javascripts + "@CalciferBundle/Resources/assets/js/events.js" %} + + {% endjavascripts %} +{% endblock %} + +{% block body -%} +