From d21c818e8477b1c5b158ef52cb10178ad7770e78 Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Sun, 21 Sep 2014 17:49:49 +0200 Subject: [PATCH] Implemented delete for repeating events. --- .../Controller/RepeatingEventController.php | 36 +++++++++++++++++++ .../views/RepeatingEvent/delete.html.twig | 29 +++++++++++++++ .../views/RepeatingEvent/index.html.twig | 3 +- 3 files changed, 67 insertions(+), 1 deletion(-) create mode 100755 src/Hackspace/Bundle/CalciferBundle/Resources/views/RepeatingEvent/delete.html.twig 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 -%} +
+
+
+
+

Möchtest du den wiederholenden Termin „{{ entity.summary }}“ wirklich löschen?

+ + Nein +
+
+
+
+{% endblock %} \ No newline at end of file diff --git a/src/Hackspace/Bundle/CalciferBundle/Resources/views/RepeatingEvent/index.html.twig b/src/Hackspace/Bundle/CalciferBundle/Resources/views/RepeatingEvent/index.html.twig index ce108c5..0d6a943 100755 --- a/src/Hackspace/Bundle/CalciferBundle/Resources/views/RepeatingEvent/index.html.twig +++ b/src/Hackspace/Bundle/CalciferBundle/Resources/views/RepeatingEvent/index.html.twig @@ -47,7 +47,8 @@ {{ entity.getFormatedRepeatPattern() }} - Bearbeiten + Bearbeiten | + Löschen {% endfor %}