mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-14 14:24:24 +00:00
clean code of usnused methods
This commit is contained in:
parent
fa3245b99b
commit
cbf9cee65c
@ -4,7 +4,6 @@ namespace Chill\CustomFieldsBundle\Controller;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Chill\CustomFieldsBundle\Form\DataTransformer\CustomFieldsGroupToIdTransformer;
|
||||
use Chill\CustomFieldsBundle\Entity\CustomField;
|
||||
|
||||
/**
|
||||
@ -14,40 +13,6 @@ use Chill\CustomFieldsBundle\Entity\CustomField;
|
||||
class CustomFieldController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Lists all CustomField entities.
|
||||
*
|
||||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$entities = $em->getRepository('ChillCustomFieldsBundle:CustomField')->findAll();
|
||||
|
||||
//prepare form for new custom type
|
||||
$fieldChoices = array();
|
||||
foreach ($this->get('chill.custom_field.provider')->getAllFields()
|
||||
as $key => $customType) {
|
||||
$fieldChoices[$key] = $customType->getName();
|
||||
}
|
||||
$form = $this->get('form.factory')
|
||||
->createNamedBuilder(null, 'form', null, array(
|
||||
'method' => 'GET',
|
||||
'action' => $this->generateUrl('customfield_new'),
|
||||
'csrf_protection' => false
|
||||
))
|
||||
->add('type', 'choice', array(
|
||||
'choices' => $fieldChoices
|
||||
))
|
||||
->getForm();
|
||||
|
||||
return $this->render('ChillCustomFieldsBundle:CustomField:index.html.twig', array(
|
||||
'entities' => $entities,
|
||||
'form' => $form->createView()
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new CustomField entity.
|
||||
*
|
||||
@ -124,6 +89,7 @@ class CustomFieldController extends Controller
|
||||
/**
|
||||
* Finds and displays a CustomField entity.
|
||||
*
|
||||
* @deprecated is not used since there is no link to show action
|
||||
*/
|
||||
public function showAction($id)
|
||||
{
|
||||
@ -135,12 +101,8 @@ class CustomFieldController extends Controller
|
||||
throw $this->createNotFoundException('Unable to find CustomField entity.');
|
||||
}
|
||||
|
||||
$deleteForm = $this->createDeleteForm($id);
|
||||
|
||||
return $this->render('ChillCustomFieldsBundle:CustomField:show.html.twig', array(
|
||||
'entity' => $entity,
|
||||
'delete_form' => $deleteForm->createView(),
|
||||
));
|
||||
'entity' => $entity, ));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -158,12 +120,10 @@ class CustomFieldController extends Controller
|
||||
}
|
||||
|
||||
$editForm = $this->createEditForm($entity, $entity->getType());
|
||||
$deleteForm = $this->createDeleteForm($id);
|
||||
|
||||
return $this->render('ChillCustomFieldsBundle:CustomField:edit.html.twig', array(
|
||||
'entity' => $entity,
|
||||
'edit_form' => $editForm->createView(),
|
||||
'delete_form' => $deleteForm->createView(),
|
||||
));
|
||||
}
|
||||
|
||||
@ -179,7 +139,8 @@ class CustomFieldController extends Controller
|
||||
$form = $this->createForm('custom_field_choice', $entity, array(
|
||||
'action' => $this->generateUrl('customfield_update', array('id' => $entity->getId())),
|
||||
'method' => 'PUT',
|
||||
'type' => $type
|
||||
'type' => $type,
|
||||
'group_widget' => 'hidden'
|
||||
));
|
||||
|
||||
$form->add('submit', 'submit', array('label' => 'Update'));
|
||||
@ -200,7 +161,6 @@ class CustomFieldController extends Controller
|
||||
throw $this->createNotFoundException('Unable to find CustomField entity.');
|
||||
}
|
||||
|
||||
$deleteForm = $this->createDeleteForm($id);
|
||||
$editForm = $this->createEditForm($entity, $entity->getType());
|
||||
$editForm->handleRequest($request);
|
||||
|
||||
@ -213,48 +173,6 @@ class CustomFieldController extends Controller
|
||||
return $this->render('ChillCustomFieldsBundle:CustomField:edit.html.twig', array(
|
||||
'entity' => $entity,
|
||||
'edit_form' => $editForm->createView(),
|
||||
'delete_form' => $deleteForm->createView(),
|
||||
));
|
||||
}
|
||||
/**
|
||||
* Deletes a CustomField entity.
|
||||
*
|
||||
*/
|
||||
public function deleteAction(Request $request, $id)
|
||||
{
|
||||
$form = $this->createDeleteForm($id);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isValid()) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$entity = $em->getRepository('ChillCustomFieldsBundle:CustomField')->find($id);
|
||||
|
||||
if (!$entity) {
|
||||
throw $this->createNotFoundException('Unable to find CustomField entity.');
|
||||
}
|
||||
|
||||
$em->remove($entity);
|
||||
$em->flush();
|
||||
}
|
||||
|
||||
return $this->redirect($this->generateUrl('customfield'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a form to delete a CustomField entity by id.
|
||||
*
|
||||
* @param mixed $id The entity id
|
||||
*
|
||||
* @return \Symfony\Component\Form\Form The form
|
||||
*/
|
||||
private function createDeleteForm($id)
|
||||
{
|
||||
return $this->createFormBuilder()
|
||||
->setAction($this->generateUrl('customfield_delete', array('id' => $id)))
|
||||
->setMethod('DELETE')
|
||||
->add('submit', 'submit', array('label' => 'Delete'))
|
||||
->getForm()
|
||||
;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,19 +8,6 @@ customfield_section:
|
||||
label: "Custom fields configuration"
|
||||
icons: ['asterisk']
|
||||
|
||||
customfield:
|
||||
path: /{_locale}/admin/customfield/list
|
||||
defaults: { _controller: "ChillCustomFieldsBundle:CustomField:index" }
|
||||
options:
|
||||
menus:
|
||||
admin_custom_fields:
|
||||
order: 1000
|
||||
label: "CustomFields List"
|
||||
|
||||
customfield_show:
|
||||
path: /{_locale}/admin/customfield/{id}/show
|
||||
defaults: { _controller: "ChillCustomFieldsBundle:CustomField:show" }
|
||||
|
||||
customfield_new:
|
||||
path: /{_locale}/admin/customfield/new
|
||||
defaults: { _controller: "ChillCustomFieldsBundle:CustomField:new" }
|
||||
@ -38,8 +25,3 @@ customfield_update:
|
||||
path: /{_locale}/admin/customfield/{id}/update
|
||||
defaults: { _controller: "ChillCustomFieldsBundle:CustomField:update" }
|
||||
requirements: { _method: post|put }
|
||||
|
||||
customfield_delete:
|
||||
path: /{_locale}/admin/customfield/{id}/delete
|
||||
defaults: { _controller: "ChillCustomFieldsBundle:CustomField:delete" }
|
||||
requirements: { _method: post|delete }
|
||||
|
@ -1,66 +0,0 @@
|
||||
{#
|
||||
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#}
|
||||
{% extends "ChillCustomFieldsBundle::Admin/layout.html.twig" %}
|
||||
|
||||
{% block admin_content %}
|
||||
<h1>CustomField list</h1>
|
||||
|
||||
<table class="records_list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<th>Label</th>
|
||||
<th>Type</th>
|
||||
<th>Active</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for entity in entities %}
|
||||
<tr>
|
||||
<td><a href="{{ path('customfield_show', { 'id': entity.id }) }}">{{ entity.id }}</a></td>
|
||||
<td>{{ entity.name(app.request.locale) }}</td>
|
||||
<td>{{ entity.type }}</td>
|
||||
<td>{{ entity.active }}</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{{ path('customfield_show', { 'id': entity.id }) }}">show</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{ path('customfield_edit', { 'id': entity.id }) }}">edit</a>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
{{ form_start(form) }}
|
||||
|
||||
{{ form_row(form) }}
|
||||
<button type="submit">
|
||||
Create a new entry
|
||||
</button>
|
||||
|
||||
{{ form_end(form) }}
|
||||
</li>
|
||||
</ul>
|
||||
{% endblock %}
|
Loading…
x
Reference in New Issue
Block a user