mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-14 14:24:24 +00:00
controller: merge newAction and createAction
This commit is contained in:
parent
c7ee9b8ebb
commit
4578625bb2
@ -86,33 +86,6 @@ class EventController extends Controller
|
|||||||
'q' => '@event'
|
'q' => '@event'
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new Event entity.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function createAction(Request $request)
|
|
||||||
{
|
|
||||||
$entity = new Event();
|
|
||||||
$form = $this->createCreateForm($entity);
|
|
||||||
$form->handleRequest($request);
|
|
||||||
|
|
||||||
if ($form->isValid()) {
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
|
||||||
$em->persist($entity);
|
|
||||||
$em->flush();
|
|
||||||
|
|
||||||
$this->addFlash('success', $this->get('translator')
|
|
||||||
->trans('The event was created'));
|
|
||||||
|
|
||||||
return $this->redirect($this->generateUrl('chill_event__event_show', array('event_id' => $entity->getId())));
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->render('ChillEventBundle:Event:new.html.twig', array(
|
|
||||||
'entity' => $entity,
|
|
||||||
'form' => $form->createView(),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a form to create a Event entity.
|
* Creates a form to create a Event entity.
|
||||||
@ -124,7 +97,6 @@ class EventController extends Controller
|
|||||||
private function createCreateForm(Event $entity)
|
private function createCreateForm(Event $entity)
|
||||||
{
|
{
|
||||||
$form = $this->createForm(EventType::class, $entity, array(
|
$form = $this->createForm(EventType::class, $entity, array(
|
||||||
'action' => $this->generateUrl('chill_event__event_create'),
|
|
||||||
'method' => 'POST',
|
'method' => 'POST',
|
||||||
'center' => $entity->getCenter(),
|
'center' => $entity->getCenter(),
|
||||||
'role' => new Role('CHILL_EVENT_CREATE')
|
'role' => new Role('CHILL_EVENT_CREATE')
|
||||||
@ -192,6 +164,18 @@ class EventController extends Controller
|
|||||||
$entity->setCenter($center);
|
$entity->setCenter($center);
|
||||||
|
|
||||||
$form = $this->createCreateForm($entity);
|
$form = $this->createCreateForm($entity);
|
||||||
|
$form->handleRequest($request);
|
||||||
|
|
||||||
|
if ($form->isValid()) {
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
$em->persist($entity);
|
||||||
|
$em->flush();
|
||||||
|
|
||||||
|
$this->addFlash('success', $this->get('translator')
|
||||||
|
->trans('The event was created'));
|
||||||
|
|
||||||
|
return $this->redirect($this->generateUrl('chill_event__event_show', array('event_id' => $entity->getId())));
|
||||||
|
}
|
||||||
|
|
||||||
return $this->render('ChillEventBundle:Event:new.html.twig', array(
|
return $this->render('ChillEventBundle:Event:new.html.twig', array(
|
||||||
'entity' => $entity,
|
'entity' => $entity,
|
||||||
|
@ -25,11 +25,7 @@ chill_event__event_new_pickcenter:
|
|||||||
chill_event__event_new:
|
chill_event__event_new:
|
||||||
path: /new
|
path: /new
|
||||||
defaults: { _controller: "ChillEventBundle:Event:new" }
|
defaults: { _controller: "ChillEventBundle:Event:new" }
|
||||||
|
methods: [ GET, POST ]
|
||||||
chill_event__event_create:
|
|
||||||
path: /create
|
|
||||||
defaults: { _controller: "ChillEventBundle:Event:create" }
|
|
||||||
methods: POST
|
|
||||||
|
|
||||||
chill_event__event_edit:
|
chill_event__event_edit:
|
||||||
path: /{event_id}/edit
|
path: /{event_id}/edit
|
||||||
|
Loading…
x
Reference in New Issue
Block a user