From e8c94262d0dd738aba5198f7e3db721cd3aebd87 Mon Sep 17 00:00:00 2001
From: Tim Schumacher
Date: Wed, 17 Sep 2014 17:37:54 +0200
Subject: [PATCH] Implemented deletion of events.
Fixes #16
---
.../Controller/EventController.php | 37 +++++++++++++++++++
.../Resources/assets/css/events.scss | 2 +-
.../Resources/views/Event/delete.html.twig | 29 +++++++++++++++
.../Resources/views/Event/event_box.html.twig | 7 ++++
4 files changed, 74 insertions(+), 1 deletion(-)
create mode 100755 src/Hackspace/Bundle/CalciferBundle/Resources/views/Event/delete.html.twig
diff --git a/src/Hackspace/Bundle/CalciferBundle/Controller/EventController.php b/src/Hackspace/Bundle/CalciferBundle/Controller/EventController.php
index d23aab5..3c83ff1 100755
--- a/src/Hackspace/Bundle/CalciferBundle/Controller/EventController.php
+++ b/src/Hackspace/Bundle/CalciferBundle/Controller/EventController.php
@@ -268,4 +268,41 @@ class EventController extends Controller
}
return $em;
}
+
+ /**
+ * Deletes a Event entity.
+ *
+ * @Route("/termine/{slug}/löschen", name="_delete")
+ * @Method({"GET", "POST"})
+ * @Template("CalciferBundle:Event:delete.html.twig")
+ */
+ public function deleteAction(Request $request, $slug) {
+ /** @var EntityManager $em */
+ $em = $this->getDoctrine()->getManager();
+
+ /** @var EntityRepository $repo */
+ $repo = $em->getRepository('CalciferBundle:Event');
+
+ /** @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/assets/css/events.scss b/src/Hackspace/Bundle/CalciferBundle/Resources/assets/css/events.scss
index 0dff5a8..b109b51 100755
--- a/src/Hackspace/Bundle/CalciferBundle/Resources/assets/css/events.scss
+++ b/src/Hackspace/Bundle/CalciferBundle/Resources/assets/css/events.scss
@@ -6,7 +6,7 @@
}
}
- .startdate,.location,.url,.edit {
+ .startdate,.location,.url,.edit,.delete {
display: inline;
margin: 0;
margin-right: 0.5rem;
diff --git a/src/Hackspace/Bundle/CalciferBundle/Resources/views/Event/delete.html.twig b/src/Hackspace/Bundle/CalciferBundle/Resources/views/Event/delete.html.twig
new file mode 100755
index 0000000..66a4061
--- /dev/null
+++ b/src/Hackspace/Bundle/CalciferBundle/Resources/views/Event/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 -%}
+
+{% endblock %}
\ No newline at end of file
diff --git a/src/Hackspace/Bundle/CalciferBundle/Resources/views/Event/event_box.html.twig b/src/Hackspace/Bundle/CalciferBundle/Resources/views/Event/event_box.html.twig
index fbf734a..a74377a 100755
--- a/src/Hackspace/Bundle/CalciferBundle/Resources/views/Event/event_box.html.twig
+++ b/src/Hackspace/Bundle/CalciferBundle/Resources/views/Event/event_box.html.twig
@@ -9,6 +9,13 @@
Bearbeiten
+
+
+
+
+ Löschen
+
+
{% endif %}