fix deprecations: use fqcn

This commit is contained in:
nobohan 2018-04-05 13:54:12 +02:00
parent 7ed0e3fddd
commit 762bb777c3
2 changed files with 22 additions and 18 deletions

View File

@ -5,6 +5,7 @@ namespace Chill\CustomFieldsBundle\Controller;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Chill\CustomFieldsBundle\Entity\CustomField; use Chill\CustomFieldsBundle\Entity\CustomField;
use Chill\CustomFieldsBundle\Form\CustomFieldType;
/** /**
* CustomField controller. * CustomField controller.
@ -27,14 +28,14 @@ class CustomFieldController extends Controller
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$em->persist($entity); $em->persist($entity);
$em->flush(); $em->flush();
$this->addFlash('success', $this->get('translator') $this->addFlash('success', $this->get('translator')
->trans('The custom field has been created')); ->trans('The custom field has been created'));
return $this->redirect($this->generateUrl('customfieldsgroup_show', return $this->redirect($this->generateUrl('customfieldsgroup_show',
array('id' => $entity->getCustomFieldsGroup()->getId()))); array('id' => $entity->getCustomFieldsGroup()->getId())));
} }
$this->addFlash('error', $this->get('translator') $this->addFlash('error', $this->get('translator')
->trans("The custom field form contains errors")); ->trans("The custom field form contains errors"));
@ -53,14 +54,14 @@ class CustomFieldController extends Controller
*/ */
private function createCreateForm(CustomField $entity, $type) private function createCreateForm(CustomField $entity, $type)
{ {
$form = $this->createForm('custom_field_choice', $entity, array( $form = $this->createForm(CustomFieldType::class, $entity, array(
'action' => $this->generateUrl('customfield_create', 'action' => $this->generateUrl('customfield_create',
array('type' => $type)), array('type' => $type)),
'method' => 'POST', 'method' => 'POST',
'type' => $type, 'type' => $type,
'group_widget' => ($entity->getCustomFieldsGroup()) ? 'hidden' :'entity' 'group_widget' => ($entity->getCustomFieldsGroup()) ? 'hidden' :'entity'
)); ));
$form->add('submit', 'submit', array('label' => 'Create')); $form->add('submit', 'submit', array('label' => 'Create'));
return $form; return $form;
@ -73,10 +74,10 @@ class CustomFieldController extends Controller
public function newAction(Request $request) public function newAction(Request $request)
{ {
$entity = new CustomField(); $entity = new CustomField();
//add the custom field group if defined in URL //add the custom field group if defined in URL
$cfGroupId = $request->query->get('customFieldsGroup', null); $cfGroupId = $request->query->get('customFieldsGroup', null);
if ($cfGroupId !== null) { if ($cfGroupId !== null) {
$cfGroup = $this->getDoctrine()->getManager() $cfGroup = $this->getDoctrine()->getManager()
->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup') ->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')
@ -87,7 +88,7 @@ class CustomFieldController extends Controller
} }
$entity->setCustomFieldsGroup($cfGroup); $entity->setCustomFieldsGroup($cfGroup);
} }
$form = $this->createCreateForm($entity, $request->query->get('type')); $form = $this->createCreateForm($entity, $request->query->get('type'));
return $this->render('ChillCustomFieldsBundle:CustomField:new.html.twig', array( return $this->render('ChillCustomFieldsBundle:CustomField:new.html.twig', array(
@ -130,7 +131,7 @@ class CustomFieldController extends Controller
} }
$editForm = $this->createEditForm($entity, $entity->getType()); $editForm = $this->createEditForm($entity, $entity->getType());
return $this->render('ChillCustomFieldsBundle:CustomField:edit.html.twig', array( return $this->render('ChillCustomFieldsBundle:CustomField:edit.html.twig', array(
'entity' => $entity, 'entity' => $entity,
'edit_form' => $editForm->createView(), 'edit_form' => $editForm->createView(),
@ -146,11 +147,11 @@ class CustomFieldController extends Controller
*/ */
private function createEditForm(CustomField $entity, $type) private function createEditForm(CustomField $entity, $type)
{ {
$form = $this->createForm('custom_field_choice', $entity, array( $form = $this->createForm(CustomFieldType::class, $entity, array(
'action' => $this->generateUrl('customfield_update', array('id' => $entity->getId())), 'action' => $this->generateUrl('customfield_update', array('id' => $entity->getId())),
'method' => 'PUT', 'method' => 'PUT',
'type' => $type, 'type' => $type,
'group_widget' => 'hidden' 'group_widget' => 'hidden'
)); ));
$form->add('submit', 'submit', array('label' => 'Update')); $form->add('submit', 'submit', array('label' => 'Update'));
@ -176,13 +177,13 @@ class CustomFieldController extends Controller
if ($editForm->isValid()) { if ($editForm->isValid()) {
$em->flush(); $em->flush();
$this->addFlash('success', $this->get('translator') $this->addFlash('success', $this->get('translator')
->trans("The custom field has been updated")); ->trans("The custom field has been updated"));
return $this->redirect($this->generateUrl('customfield_edit', array('id' => $id))); return $this->redirect($this->generateUrl('customfield_edit', array('id' => $id)));
} }
$this->addFlash('error', $this->get('translator') $this->addFlash('error', $this->get('translator')
->trans("The custom field form contains errors")); ->trans("The custom field form contains errors"));

View File

@ -14,6 +14,9 @@ use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup;
use Chill\CustomFieldsBundle\Entity\CustomField; use Chill\CustomFieldsBundle\Entity\CustomField;
use Chill\CustomFieldsBundle\Form\DataTransformer\CustomFieldsGroupToIdTransformer; use Chill\CustomFieldsBundle\Form\DataTransformer\CustomFieldsGroupToIdTransformer;
use Chill\CustomFieldsBundle\Entity\CustomFieldsDefaultGroup; use Chill\CustomFieldsBundle\Entity\CustomFieldsDefaultGroup;
use Chill\CustomFieldsBundle\Form\CustomFieldsGroupType;
use Chill\CustomFieldsBundle\Form\CustomFieldType;
use Chill\CustomFieldsBundle\Form\Type\CustomFieldType as FormTypeCustomField;
/** /**
* CustomFieldsGroup controller. * CustomFieldsGroup controller.
@ -127,7 +130,7 @@ class CustomFieldsGroupController extends Controller
*/ */
private function createCreateForm(CustomFieldsGroup $entity) private function createCreateForm(CustomFieldsGroup $entity)
{ {
$form = $this->createForm('custom_fields_group', $entity, array( $form = $this->createForm(CustomFieldsGroupType::class, $entity, array(
'action' => $this->generateUrl('customfieldsgroup_create'), 'action' => $this->generateUrl('customfieldsgroup_create'),
'method' => 'POST', 'method' => 'POST',
)); ));
@ -227,7 +230,7 @@ class CustomFieldsGroupController extends Controller
*/ */
private function createEditForm(CustomFieldsGroup $entity) private function createEditForm(CustomFieldsGroup $entity)
{ {
$form = $this->createForm('custom_fields_group', $entity, array( $form = $this->createForm(CustomFieldsGroupType::class, $entity, array(
'action' => $this->generateUrl('customfieldsgroup_update', array('id' => $entity->getId())), 'action' => $this->generateUrl('customfieldsgroup_update', array('id' => $entity->getId())),
'method' => 'PUT', 'method' => 'PUT',
)); ));
@ -369,7 +372,7 @@ class CustomFieldsGroupController extends Controller
throw $this->createNotFoundException('Unable to find CustomFieldsGroups entity.'); throw $this->createNotFoundException('Unable to find CustomFieldsGroups entity.');
} }
$form = $this->createForm('custom_field', null, array('group' => $entity)); $form = $this->createForm(FormTypeCustomField::class, null, array('group' => $entity));
$form->add('submit_dump', 'submit', array('label' => 'POST AND DUMP')); $form->add('submit_dump', 'submit', array('label' => 'POST AND DUMP'));
$form->add('submit_render','submit', array('label' => 'POST AND RENDER')); $form->add('submit_render','submit', array('label' => 'POST AND RENDER'));
$form->handleRequest($request); $form->handleRequest($request);