Skip to content

Commit

Permalink
Series tools added
Browse files Browse the repository at this point in the history
  • Loading branch information
mogilvie committed Feb 7, 2016
1 parent ea58e09 commit cf14457
Show file tree
Hide file tree
Showing 18 changed files with 963 additions and 255 deletions.
93 changes: 76 additions & 17 deletions Controller/EventController.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function downloadAction() {
;
$response->headers->set('Content-Type', 'multipart/alternative');
$response->headers->set('Content-Disposition', 'attachment; filename="cal.ics"');

return $response;
}

Expand Down Expand Up @@ -86,6 +86,10 @@ public function addEventAction(Request $request) {

$newEvent = new CalendarEditEvent($event);

if ($form->get('updateAttendees')->getData()) {
$newEvent->setSendUpdate();
}

$this->getEventManager()->updateDateTimes($form, $event);

$modifiedEventEntity = $loadedEvents = $this->getDispatcher()
Expand All @@ -94,6 +98,7 @@ public function addEventAction(Request $request) {

$this->getEventManager()->save($modifiedEventEntity);


return new JsonResponse($modifiedEventEntity->toArray());
}

Expand Down Expand Up @@ -123,6 +128,9 @@ public function updateEventAction(Request $request, $id) {
'method' => 'PUT',
));

$deleteForm = $this->createDeleteForm($id);
$deleteSeriesForm = $this->createDeleteSeriesForm($id);

$form->handleRequest($request);

if ($form->isSubmitted() && $form->isValid()) {
Expand All @@ -131,17 +139,26 @@ public function updateEventAction(Request $request, $id) {

$newEvent = new CalendarEditEvent($event);

if ($form->get('updateAttendees')->getData()) {
$newEvent->setSendUpdate();
}

$modifiedEventEntity = $this->getDispatcher()
->dispatch(CalendarEvents::CALENDAR_EVENT_UPDATED, $newEvent)
->getEventEntity();

$modifiedEventEntity = $this->getEventManager()->updateEvent($modifiedEventEntity);

return new JsonResponse($modifiedEventEntity->toArray());
$response = new JsonResponse($modifiedEventEntity->toArray());

return $response;
}


return $this->render('SpecShaperCalendarBundle:Event:eventModal.html.twig', array(
'form' => $form->createView(),
'deleteForm' => $deleteForm->createView(),
'deleteSeriesForm' => $deleteSeriesForm->createView(),
));
}

Expand Down Expand Up @@ -173,41 +190,49 @@ public function updateDateTimeAction(Request $request, $id) {
$em->persist($event);
$em->flush();



return new JsonResponse($event->toArray());
}



/**
* @param Request $request
* @Route("/{id}/delete", name="event_delete")
* @Route("/{id}/deleteseries", name="event_deleteseries")
* @Method({"DELETE"})
*/
public function deleteEventAction(Request $request, $id) {

public function deleteSeriesEventAction(Request $request, $id) {
$event = $this->getEventManager()->getEvent($id);

$removeEvent = new CalendarEditEvent($event);

$this->getDispatcher()
->dispatch(CalendarEvents::CALENDAR_EVENT_REMOVED, $removeEvent)
->getEventEntity();

$this->getEventManager()->deleteEvent($event);
$deletedIdArray = $this->getEventManager()->deleteEventSeries($event);

return new JsonResponse("deleted");
return new JsonResponse($deletedIdArray);
}

/**
* @param Request $request
* @Route("/{id}/deleteseries", name="event_deleteseries")
* @Method({"POST"})
* @Route("/{id}/delete", name="event_delete")
* @Method({"DELETE"})
*/
public function deleteSeriesEventAction(Request $request) {
public function deleteEventAction(Request $request, $id) {

$this->getEventManager()->deleteEvent($id);
$event = $this->getEventManager()->getEvent($id);

$removeEvent = new CalendarEditEvent($event);

$this->getDispatcher()
->dispatch(CalendarEvents::CALENDAR_EVENT_REMOVED, $removeEvent)
->getEventEntity();

$deletedIdArray = $this->getEventManager()->deleteEvent($event);

return new JsonResponse("deleted");
return new JsonResponse($deletedIdArray);
}

/**
Expand All @@ -228,6 +253,40 @@ public function getEmailAddressesAction() {
));
}

/**
* Creates a form to delete a AvailableDiscipline entity by id.
*
* @since Available since Release 1.0.0
*
* @param mixed $id The entity id
*
* @return \Symfony\Component\Form\Form The form
*/
protected function createDeleteForm($id) {
return $this->createFormBuilder()
->setAction($this->generateUrl('event_delete', array('id' => $id)))
->setMethod('DELETE')
->getForm()
;
}

/**
* Creates a form to delete a AvailableDiscipline entity by id.
*
* @since Available since Release 1.0.0
*
* @param mixed $id The entity id
*
* @return \Symfony\Component\Form\Form The form
*/
protected function createDeleteSeriesForm($id) {
return $this->createFormBuilder()
->setAction($this->generateUrl('event_deleteseries', array('id' => $id)))
->setMethod('DELETE')
->getForm()
;
}

/**
* Get the Calendar Event CalendarEventManager.
*
Expand Down
Loading

0 comments on commit cf14457

Please sign in to comment.