mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-01 20:43:49 +00:00
replace old method of getting translator with injection of translatorInterface
This commit is contained in:
@@ -18,12 +18,15 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
/**
|
||||
* Class CustomFieldController.
|
||||
*/
|
||||
class CustomFieldController extends AbstractController
|
||||
{
|
||||
public function __construct(private readonly TranslatorInterface $translator){}
|
||||
|
||||
/**
|
||||
* Creates a new CustomField entity.
|
||||
*
|
||||
@@ -40,13 +43,13 @@ class CustomFieldController extends AbstractController
|
||||
$em->persist($entity);
|
||||
$em->flush();
|
||||
|
||||
$this->addFlash('success', $this->get('translator')
|
||||
$this->addFlash('success', $this->translator
|
||||
->trans('The custom field has been created'));
|
||||
|
||||
return $this->redirectToRoute('customfieldsgroup_show', ['id' => $entity->getCustomFieldsGroup()->getId()]);
|
||||
}
|
||||
|
||||
$this->addFlash('error', $this->get('translator')
|
||||
$this->addFlash('error', $this->translator
|
||||
->trans('The custom field form contains errors'));
|
||||
|
||||
return $this->render('@ChillCustomFields/CustomField/new.html.twig', [
|
||||
@@ -130,13 +133,13 @@ class CustomFieldController extends AbstractController
|
||||
if ($editForm->isSubmitted() && $editForm->isValid()) {
|
||||
$em->flush();
|
||||
|
||||
$this->addFlash('success', $this->get('translator')
|
||||
$this->addFlash('success', $this->translator
|
||||
->trans('The custom field has been updated'));
|
||||
|
||||
return $this->redirectToRoute('customfield_edit', ['id' => $id]);
|
||||
}
|
||||
|
||||
$this->addFlash('error', $this->get('translator')
|
||||
$this->addFlash('error', $this->translator
|
||||
->trans('The custom field form contains errors'));
|
||||
|
||||
return $this->render('@ChillCustomFields/CustomField/edit.html.twig', [
|
||||
|
Reference in New Issue
Block a user