mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-14 06:14:23 +00:00
Allow the modification of event + adding the prefix chill_even to all the route
This commit is contained in:
parent
fdb2c094a6
commit
cf7f8a929b
@ -42,7 +42,7 @@ class EventController extends Controller
|
|||||||
$em->persist($entity);
|
$em->persist($entity);
|
||||||
$em->flush();
|
$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(
|
return $this->render('ChillEventBundle:Event:new.html.twig', array(
|
||||||
@ -61,7 +61,7 @@ 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('event_create'),
|
'action' => $this->generateUrl('chill_event__event_create'),
|
||||||
'method' => 'POST'
|
'method' => 'POST'
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -152,18 +152,18 @@ class EventController extends Controller
|
|||||||
* Displays a form to edit an existing Event entity.
|
* Displays a form to edit an existing Event entity.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function editAction($id)
|
public function editAction($event_id)
|
||||||
{
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
$entity = $em->getRepository('ChillEventBundle:Event')->find($id);
|
$entity = $em->getRepository('ChillEventBundle:Event')->find($event_id);
|
||||||
|
|
||||||
if (!$entity) {
|
if (!$entity) {
|
||||||
throw $this->createNotFoundException('Unable to find Event entity.');
|
throw $this->createNotFoundException('Unable to find Event entity.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$editForm = $this->createEditForm($entity);
|
$editForm = $this->createEditForm($entity);
|
||||||
$deleteForm = $this->createDeleteForm($id);
|
$deleteForm = $this->createDeleteForm($event_id);
|
||||||
|
|
||||||
return $this->render('ChillEventBundle:Event:edit.html.twig', array(
|
return $this->render('ChillEventBundle:Event:edit.html.twig', array(
|
||||||
'entity' => $entity,
|
'entity' => $entity,
|
||||||
@ -181,11 +181,12 @@ class EventController extends Controller
|
|||||||
*/
|
*/
|
||||||
private function createEditForm(Event $entity)
|
private function createEditForm(Event $entity)
|
||||||
{
|
{
|
||||||
$form = $this->createForm(new EventType(), $entity, array(
|
$form = $this->createForm(EventType::class, $entity, array(
|
||||||
'action' => $this->generateUrl('event_update', array('id' => $entity->getId())),
|
'action' => $this->generateUrl('chill_event__event_update', array('event_id' => $entity->getId())),
|
||||||
'method' => 'PUT',
|
'method' => 'PUT',
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
$form->add('submit', 'submit', array('label' => 'Update'));
|
$form->add('submit', 'submit', array('label' => 'Update'));
|
||||||
|
|
||||||
return $form;
|
return $form;
|
||||||
@ -194,24 +195,24 @@ class EventController extends Controller
|
|||||||
* Edits an existing Event entity.
|
* Edits an existing Event entity.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function updateAction(Request $request, $id)
|
public function updateAction(Request $request, $event_id)
|
||||||
{
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
$entity = $em->getRepository('ChillEventBundle:Event')->find($id);
|
$entity = $em->getRepository('ChillEventBundle:Event')->find($event_id);
|
||||||
|
|
||||||
if (!$entity) {
|
if (!$entity) {
|
||||||
throw $this->createNotFoundException('Unable to find Event entity.');
|
throw $this->createNotFoundException('Unable to find Event entity.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$deleteForm = $this->createDeleteForm($id);
|
$deleteForm = $this->createDeleteForm($event_id);
|
||||||
$editForm = $this->createEditForm($entity);
|
$editForm = $this->createEditForm($entity);
|
||||||
$editForm->handleRequest($request);
|
$editForm->handleRequest($request);
|
||||||
|
|
||||||
if ($editForm->isValid()) {
|
if ($editForm->isValid()) {
|
||||||
$em->flush();
|
$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(
|
return $this->render('ChillEventBundle:Event:edit.html.twig', array(
|
||||||
@ -224,14 +225,14 @@ class EventController extends Controller
|
|||||||
* Deletes a Event entity.
|
* 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);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
if ($form->isValid()) {
|
if ($form->isValid()) {
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
$entity = $em->getRepository('ChillEventBundle:Event')->find($id);
|
$entity = $em->getRepository('ChillEventBundle:Event')->find($event_id);
|
||||||
|
|
||||||
if (!$entity) {
|
if (!$entity) {
|
||||||
throw $this->createNotFoundException('Unable to find Event 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.
|
* 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
|
* @return \Symfony\Component\Form\Form The form
|
||||||
*/
|
*/
|
||||||
private function createDeleteForm($id)
|
private function createDeleteForm($event_id)
|
||||||
{
|
{
|
||||||
return $this->createFormBuilder()
|
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')
|
->setMethod('DELETE')
|
||||||
->add('submit', 'submit', array('label' => 'Delete'))
|
->add('submit', 'submit', array('label' => 'Delete'))
|
||||||
->getForm()
|
->getForm()
|
||||||
|
@ -68,7 +68,7 @@ class ParticipationController extends Controller
|
|||||||
'The participation was created'
|
'The participation was created'
|
||||||
));
|
));
|
||||||
|
|
||||||
return $this->redirectToRoute('event_show', array(
|
return $this->redirectToRoute('chill_event__event_show', array(
|
||||||
'event_id' => $participation->getEvent()->getId()
|
'event_id' => $participation->getEvent()->getId()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -205,7 +205,7 @@ class ParticipationController extends Controller
|
|||||||
'The participation was updated'
|
'The participation was updated'
|
||||||
));
|
));
|
||||||
|
|
||||||
return $this->redirectToRoute('event_show', array(
|
return $this->redirectToRoute('chill_event__event_show', array(
|
||||||
'event_id' => $participation->getEvent()->getId()
|
'event_id' => $participation->getEvent()->getId()
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -8,11 +8,11 @@ chill_event_list_most_recent:
|
|||||||
label: Events
|
label: Events
|
||||||
icons: [calendar]
|
icons: [calendar]
|
||||||
|
|
||||||
event_show:
|
chill_event__event_show:
|
||||||
path: /{event_id}/show
|
path: /{event_id}/show
|
||||||
defaults: { _controller: "ChillEventBundle:Event:show" }
|
defaults: { _controller: "ChillEventBundle:Event:show" }
|
||||||
|
|
||||||
event_new:
|
chill_event__event_new:
|
||||||
path: /new
|
path: /new
|
||||||
defaults: { _controller: "ChillEventBundle:Event:new" }
|
defaults: { _controller: "ChillEventBundle:Event:new" }
|
||||||
options:
|
options:
|
||||||
@ -22,22 +22,21 @@ event_new:
|
|||||||
label: Add an event
|
label: Add an event
|
||||||
icons: [plus, calendar-o]
|
icons: [plus, calendar-o]
|
||||||
|
|
||||||
|
chill_event__event_create:
|
||||||
event_create:
|
|
||||||
path: /create
|
path: /create
|
||||||
defaults: { _controller: "ChillEventBundle:Event:create" }
|
defaults: { _controller: "ChillEventBundle:Event:create" }
|
||||||
methods: POST
|
methods: POST
|
||||||
|
|
||||||
event_edit:
|
chill_event__event_edit:
|
||||||
path: /{id}/edit
|
path: /{event_id}/edit
|
||||||
defaults: { _controller: "ChillEventBundle:Event:edit" }
|
defaults: { _controller: "ChillEventBundle:Event:edit" }
|
||||||
|
|
||||||
event_update:
|
chill_event__event_update:
|
||||||
path: /{id}/update
|
path: /{event_id}/update
|
||||||
defaults: { _controller: "ChillEventBundle:Event:update" }
|
defaults: { _controller: "ChillEventBundle:Event:update" }
|
||||||
methods: [POST, PUT]
|
methods: [POST, PUT]
|
||||||
|
|
||||||
event_delete:
|
chill_event__event_delete:
|
||||||
path: /{id}/delete
|
path: /{event_id}/delete
|
||||||
defaults: { _controller: "ChillEventBundle:Event:delete" }
|
defaults: { _controller: "ChillEventBundle:Event:delete" }
|
||||||
methods: [POST, DELETE]
|
methods: [POST, DELETE]
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
{% extends '::base.html.twig' %}
|
{% extends 'ChillEventBundle::layout.html.twig' %}
|
||||||
|
|
||||||
{% block body -%}
|
{% block event_content -%}
|
||||||
<h1>Event edit</h1>
|
<h1>Event edit</h1>
|
||||||
|
|
||||||
{{ form(edit_form) }}
|
{{ form(edit_form) }}
|
||||||
|
|
||||||
<ul class="record_actions">
|
<ul class="record_actions">
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ path('event') }}">
|
<a href="{{ path('chill_event_list_most_recent') }}">
|
||||||
Back to the list
|
Back to the list
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
@ -15,16 +15,16 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
{% for entity in entities %}
|
{% for entity in entities %}
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="{{ path('event_show', { 'id': entity.id }) }}">{{ entity.id }}</a></td>
|
<td><a href="{{ path('chill_event__event_show', { 'id': entity.id }) }}">{{ entity.id }}</a></td>
|
||||||
<td>{{ entity.label }}</td>
|
<td>{{ entity.label }}</td>
|
||||||
<td>{% if entity.date %}{{ entity.date|date('Y-m-d H:i:s') }}{% endif %}</td>
|
<td>{% if entity.date %}{{ entity.date|date('Y-m-d H:i:s') }}{% endif %}</td>
|
||||||
<td>
|
<td>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ path('event_show', { 'id': entity.id }) }}">show</a>
|
<a href="{{ path('chill_event__event_show', { 'id': entity.id }) }}">show</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ path('event_edit', { 'id': entity.id }) }}">edit</a>
|
<a href="{{ path('chill_event__event_edit', { 'id': entity.id }) }}">edit</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</td>
|
</td>
|
||||||
@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ path('event_new') }}">
|
<a href="{{ path('chill_event__event_new') }}">
|
||||||
Create a new entry
|
Create a new entry
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
@ -23,12 +23,12 @@
|
|||||||
<ul class="record_actions">
|
<ul class="record_actions">
|
||||||
<li>
|
<li>
|
||||||
{# {% if is_granted('CHILL_EVENT_SEE_DETAILS', event) %} #}
|
{# {% if is_granted('CHILL_EVENT_SEE_DETAILS', event) %} #}
|
||||||
<a href="{{ path('event_show', { 'event_id' : event.id } ) }}" class="sc-button btn-action">
|
<a href="{{ path('chill_event__event_show', { 'event_id' : event.id } ) }}" class="sc-button btn-action">
|
||||||
{{ 'See'|trans }}
|
{{ 'See'|trans }}
|
||||||
</a>
|
</a>
|
||||||
{# {% endif %} #}
|
{# {% endif %} #}
|
||||||
{% if is_granted('CHILL_EVENT_UPDATE', event) %}
|
{% if is_granted('CHILL_EVENT_UPDATE', event) %}
|
||||||
<a href="#" class="sc-button btn-edit">
|
<a href="{{ path('chill_event__event_edit', { 'event_id' : event.id } ) }}" class="sc-button btn-edit">
|
||||||
{{ 'Edit'|trans }}
|
{{ 'Edit'|trans }}
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -44,8 +44,8 @@
|
|||||||
|
|
||||||
<ul class="record_actions">
|
<ul class="record_actions">
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ path('event_new') }}" class="sc-button btn-create" >
|
<a href="{{ path('chill_event__event_new') }}" class="sc-button btn-create" >
|
||||||
{{ 'New event'|trans }}
|
{{ 'New event'|trans }}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
<ul class="record_actions">
|
<ul class="record_actions">
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ path('event') }}">
|
<a href="{{ path('chill_event_list_most_recent') }}">
|
||||||
Back to the list
|
Back to the list
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
<ul class="record_actions">
|
<ul class="record_actions">
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ path('event_edit', { 'id': event.id }) }}" class="sc-button btn-edit">
|
<a href="{{ path('chill_event__event_edit', { 'id': event.id }) }}" class="sc-button btn-edit">
|
||||||
{{ 'Edit'|trans }}
|
{{ 'Edit'|trans }}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
<ul class="record_actions">
|
<ul class="record_actions">
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ path('event_show', { 'event_id' : participation.event.id } ) }}" class="sc-button btn-cancel">
|
<a href="{{ path('chill_event__event_show', { 'event_id' : participation.event.id } ) }}" class="sc-button btn-cancel">
|
||||||
{{ 'Back to the event'|trans }}
|
{{ 'Back to the event'|trans }}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
<ul class="record_actions">
|
<ul class="record_actions">
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ path('event_show', { 'event_id' : participation.event.id } ) }}" class="sc-button btn-cancel">
|
<a href="{{ path('chill_event__event_show', { 'event_id' : participation.event.id } ) }}" class="sc-button btn-cancel">
|
||||||
{{ 'Back to the event'|trans }}
|
{{ 'Back to the event'|trans }}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user