clean code of usnused methods

This commit is contained in:
2015-11-27 13:51:36 +01:00
parent fa3245b99b
commit cbf9cee65c
3 changed files with 4 additions and 170 deletions

View File

@@ -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()
;
}
}