mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-30 14:06:13 +00:00
autowire+autoconfigure service to avoid container error with parameter_bag + add dep injection + comment debug
This commit is contained in:
parent
4f90561362
commit
5ea0126a03
@ -17,6 +17,7 @@ use Chill\CustomFieldsBundle\Entity\CustomFieldsDefaultGroup;
|
||||
use Chill\CustomFieldsBundle\Form\CustomFieldsGroupType;
|
||||
use Chill\CustomFieldsBundle\Form\CustomFieldType;
|
||||
use Chill\CustomFieldsBundle\Form\Type\CustomFieldType as FormTypeCustomField;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
/**
|
||||
* Class CustomFieldsGroupController
|
||||
@ -31,14 +32,23 @@ class CustomFieldsGroupController extends AbstractController
|
||||
*/
|
||||
private $customfieldProvider;
|
||||
|
||||
/**
|
||||
* @var TranslatorInterface
|
||||
*/
|
||||
private $translator;
|
||||
|
||||
/**
|
||||
* CustomFieldsGroupController constructor.
|
||||
*
|
||||
* @param CustomFieldProvider $customFieldProvider
|
||||
* @param TranslatorInterface $translator
|
||||
*/
|
||||
public function __construct(CustomFieldProvider $customFieldProvider)
|
||||
{
|
||||
public function __construct(
|
||||
CustomFieldProvider $customFieldProvider,
|
||||
TranslatorInterface $translator
|
||||
) {
|
||||
$this->customfieldProvider = $customFieldProvider;
|
||||
$this->translator = $translator;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -122,13 +132,13 @@ class CustomFieldsGroupController extends AbstractController
|
||||
$em->persist($entity);
|
||||
$em->flush();
|
||||
|
||||
$this->addFlash('success', $this->get('translator')
|
||||
$this->addFlash('success', $this->translator
|
||||
->trans("The custom fields group has been created"));
|
||||
|
||||
return $this->redirect($this->generateUrl('customfieldsgroup_show', array('id' => $entity->getId())));
|
||||
}
|
||||
|
||||
$this->addFlash('error', $this->get('translator')
|
||||
$this->addFlash('error', $this->translator
|
||||
->trans("The custom fields group form contains errors"));
|
||||
|
||||
return $this->render('ChillCustomFieldsBundle:CustomFieldsGroup:new.html.twig', array(
|
||||
@ -305,13 +315,13 @@ class CustomFieldsGroupController extends AbstractController
|
||||
if ($editForm->isValid()) {
|
||||
$em->flush();
|
||||
|
||||
$this->addFlash('success', $this->get('translator')
|
||||
$this->addFlash('success', $this->translator
|
||||
->trans("The custom fields group has been updated"));
|
||||
|
||||
return $this->redirect($this->generateUrl('customfieldsgroup_edit', array('id' => $id)));
|
||||
}
|
||||
|
||||
$this->addFlash('error', $this->get('translator')
|
||||
$this->addFlash('error', $this->translator
|
||||
->trans("The custom fields group form contains errors"));
|
||||
|
||||
return $this->render('ChillCustomFieldsBundle:CustomFieldsGroup:edit.html.twig', array(
|
||||
@ -361,7 +371,7 @@ class CustomFieldsGroupController extends AbstractController
|
||||
$em->persist($newCFDefaultGroup);
|
||||
$em->flush();
|
||||
|
||||
$this->addFlash('success', $this->get('translator')
|
||||
$this->addFlash('success', $this->translator
|
||||
->trans("The default custom fields group has been changed"));
|
||||
|
||||
return $this->redirect($this->generateUrl('customfieldsgroup'));
|
||||
@ -404,8 +414,8 @@ class CustomFieldsGroupController extends AbstractController
|
||||
));
|
||||
}
|
||||
|
||||
var_dump($form->getData());
|
||||
var_dump(json_enccode($form->getData()));
|
||||
//dump($form->getData());
|
||||
//dump(json_enccode($form->getData()));
|
||||
}
|
||||
|
||||
|
||||
|
@ -6,4 +6,14 @@ services:
|
||||
Chill\CustomFieldsBundle\Controller\CustomFieldsGroupController:
|
||||
arguments:
|
||||
$customFieldProvider: '@chill.custom_field.provider'
|
||||
$translator: '@Symfony\Contracts\Translation\TranslatorInterface'
|
||||
tags: ['controller.service_arguments']
|
||||
## TODO
|
||||
## cfr. https://github.com/symfony/symfony/issues/27436#issuecomment-393576416
|
||||
#
|
||||
# " An exception has been thrown during the rendering of a template
|
||||
# ("The "Chill\CustomFieldsBundle\Controller\CustomFieldsGroupController::getParameter()" method is missing a parameter bag
|
||||
# to work properly. Did you forget to register your controller as a service subscriber? This can be fixed
|
||||
# either by using autoconfiguration or by manually wiring a "parameter_bag" in the service locator passed to the controller.").
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
|
Loading…
x
Reference in New Issue
Block a user