Implemented delete for repeating events.
This commit is contained in:
parent
e6c6e0ee35
commit
d21c818e84
3 changed files with 67 additions and 1 deletions
|
@ -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,
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
{% extends 'CalciferBundle::layout.html.twig' %}
|
||||
|
||||
{% block css %}
|
||||
{% stylesheets filter="compass"
|
||||
"@CalciferBundle/Resources/assets/css/events.scss" %}
|
||||
<link rel="stylesheet" href="{{ asset_url }}"/>
|
||||
{% endstylesheets %}
|
||||
{% endblock %}
|
||||
|
||||
{% block javascripts %}
|
||||
{% javascripts
|
||||
"@CalciferBundle/Resources/assets/js/events.js" %}
|
||||
<script src="{{ asset_url }}"></script>
|
||||
{% endjavascripts %}
|
||||
{% endblock %}
|
||||
|
||||
{% block body -%}
|
||||
<div class="ui one column page grid">
|
||||
<div class="ui column">
|
||||
<div class="ui segment event box">
|
||||
<form class="ui form" method="post">
|
||||
<p>Möchtest du den wiederholenden Termin <strong>„{{ entity.summary }}“</strong> wirklich löschen?</p>
|
||||
<button name="confirmation" value="true" class="ui button red">Ja</button>
|
||||
<a href="{{ path('_show', {'slug' : entity.slug }) }}" class="ui button green">Nein</a>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -47,7 +47,8 @@
|
|||
{{ entity.getFormatedRepeatPattern() }}
|
||||
</td>
|
||||
<td>
|
||||
<a href="{{ path('repeating_event_edit', {'slug':entity.slug}) }}">Bearbeiten</a>
|
||||
<a href="{{ path('repeating_event_edit', {'slug':entity.slug}) }}">Bearbeiten</a> |
|
||||
<a href="{{ path('repeating_event_delete', {'slug':entity.slug}) }}">Löschen</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
|
Reference in a new issue