Allow the modification of event + adding the prefix chill_even to all the route

This commit is contained in:
Marc Ducobu
2016-03-24 18:03:45 +01:00
parent fdb2c094a6
commit cf7f8a929b
10 changed files with 44 additions and 44 deletions

View File

@@ -42,7 +42,7 @@ class EventController extends Controller
$em->persist($entity);
$em->flush();
return $this->redirect($this->generateUrl('event_show', array('event_id' => $entity->getId())));
return $this->redirect($this->generateUrl('chill_event__event_show', array('event_id' => $entity->getId())));
}
return $this->render('ChillEventBundle:Event:new.html.twig', array(
@@ -61,7 +61,7 @@ class EventController extends Controller
private function createCreateForm(Event $entity)
{
$form = $this->createForm(EventType::class, $entity, array(
'action' => $this->generateUrl('event_create'),
'action' => $this->generateUrl('chill_event__event_create'),
'method' => 'POST'
));
@@ -152,18 +152,18 @@ class EventController extends Controller
* Displays a form to edit an existing Event entity.
*
*/
public function editAction($id)
public function editAction($event_id)
{
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('ChillEventBundle:Event')->find($id);
$entity = $em->getRepository('ChillEventBundle:Event')->find($event_id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find Event entity.');
}
$editForm = $this->createEditForm($entity);
$deleteForm = $this->createDeleteForm($id);
$deleteForm = $this->createDeleteForm($event_id);
return $this->render('ChillEventBundle:Event:edit.html.twig', array(
'entity' => $entity,
@@ -181,11 +181,12 @@ class EventController extends Controller
*/
private function createEditForm(Event $entity)
{
$form = $this->createForm(new EventType(), $entity, array(
'action' => $this->generateUrl('event_update', array('id' => $entity->getId())),
$form = $this->createForm(EventType::class, $entity, array(
'action' => $this->generateUrl('chill_event__event_update', array('event_id' => $entity->getId())),
'method' => 'PUT',
));
$form->add('submit', 'submit', array('label' => 'Update'));
return $form;
@@ -194,24 +195,24 @@ class EventController extends Controller
* Edits an existing Event entity.
*
*/
public function updateAction(Request $request, $id)
public function updateAction(Request $request, $event_id)
{
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('ChillEventBundle:Event')->find($id);
$entity = $em->getRepository('ChillEventBundle:Event')->find($event_id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find Event entity.');
}
$deleteForm = $this->createDeleteForm($id);
$deleteForm = $this->createDeleteForm($event_id);
$editForm = $this->createEditForm($entity);
$editForm->handleRequest($request);
if ($editForm->isValid()) {
$em->flush();
return $this->redirect($this->generateUrl('event_edit', array('id' => $id)));
return $this->redirect($this->generateUrl('chill_event__event_edit', array('event_id' => $event_id)));
}
return $this->render('ChillEventBundle:Event:edit.html.twig', array(
@@ -224,14 +225,14 @@ class EventController extends Controller
* Deletes a Event entity.
*
*/
public function deleteAction(Request $request, $id)
public function deleteAction(Request $request, $event_id)
{
$form = $this->createDeleteForm($id);
$form = $this->createDeleteForm($event_id);
$form->handleRequest($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('ChillEventBundle:Event')->find($id);
$entity = $em->getRepository('ChillEventBundle:Event')->find($event_id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find Event entity.');
@@ -247,14 +248,14 @@ class EventController extends Controller
/**
* Creates a form to delete a Event entity by id.
*
* @param mixed $id The entity id
* @param mixed $event_id The event id
*
* @return \Symfony\Component\Form\Form The form
*/
private function createDeleteForm($id)
private function createDeleteForm($event_id)
{
return $this->createFormBuilder()
->setAction($this->generateUrl('event_delete', array('id' => $id)))
->setAction($this->generateUrl('chill_event__event_delete', array('event_id' => $event_id)))
->setMethod('DELETE')
->add('submit', 'submit', array('label' => 'Delete'))
->getForm()

View File

@@ -68,7 +68,7 @@ class ParticipationController extends Controller
'The participation was created'
));
return $this->redirectToRoute('event_show', array(
return $this->redirectToRoute('chill_event__event_show', array(
'event_id' => $participation->getEvent()->getId()
));
}
@@ -205,7 +205,7 @@ class ParticipationController extends Controller
'The participation was updated'
));
return $this->redirectToRoute('event_show', array(
return $this->redirectToRoute('chill_event__event_show', array(
'event_id' => $participation->getEvent()->getId()
));