mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-28 13:06:13 +00:00
replace get->('translator') with injection of translatorInterface
This commit is contained in:
parent
2a151d13ed
commit
89a185a34f
@ -26,6 +26,7 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Validator\ConstraintViolationListInterface;
|
||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use function array_filter;
|
||||
|
||||
/**
|
||||
@ -33,24 +34,12 @@ use function array_filter;
|
||||
*/
|
||||
class AccompanyingPeriodController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* @var EventDispatcherInterface
|
||||
*/
|
||||
protected $eventDispatcher;
|
||||
|
||||
/**
|
||||
* @var ValidatorInterface
|
||||
*/
|
||||
protected $validator;
|
||||
|
||||
public function __construct(
|
||||
protected AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository,
|
||||
EventDispatcherInterface $eventDispatcher,
|
||||
ValidatorInterface $validator
|
||||
) {
|
||||
$this->eventDispatcher = $eventDispatcher;
|
||||
$this->validator = $validator;
|
||||
}
|
||||
private readonly EventDispatcherInterface $eventDispatcher,
|
||||
private readonly ValidatorInterface $validator,
|
||||
private readonly TranslatorInterface $translator
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
@ -65,7 +54,7 @@ class AccompanyingPeriodController extends AbstractController
|
||||
|
||||
if (false === $person->isOpen()) {
|
||||
$this->get('session')->getFlashBag()
|
||||
->add('error', $this->get('translator')
|
||||
->add('error', $this->translator
|
||||
->trans(
|
||||
'Beware period is closed',
|
||||
['%name%' => $person->__toString()]
|
||||
@ -92,7 +81,7 @@ class AccompanyingPeriodController extends AbstractController
|
||||
|
||||
if (0 === \count($errors)) {
|
||||
$this->get('session')->getFlashBag()
|
||||
->add('success', $this->get('translator')
|
||||
->add('success', $this->translator
|
||||
->trans('An accompanying period has been closed.', [
|
||||
'%name%' => $person->__toString(),
|
||||
]));
|
||||
@ -104,7 +93,7 @@ class AccompanyingPeriodController extends AbstractController
|
||||
]);
|
||||
}
|
||||
$this->get('session')->getFlashBag()
|
||||
->add('error', $this->get('translator')
|
||||
->add('error', $this->translator
|
||||
->trans('Error! Period not closed!'));
|
||||
|
||||
foreach ($errors as $error) {
|
||||
@ -115,7 +104,7 @@ class AccompanyingPeriodController extends AbstractController
|
||||
$this->get('session')->getFlashBag()
|
||||
->add(
|
||||
'error',
|
||||
$this->get('translator')
|
||||
$this->translator
|
||||
->trans('Pediod closing form is not valid')
|
||||
);
|
||||
|
||||
@ -175,7 +164,7 @@ class AccompanyingPeriodController extends AbstractController
|
||||
$em->flush();
|
||||
$flashBag->add(
|
||||
'success',
|
||||
$this->get('translator')->trans(
|
||||
$this->translator->trans(
|
||||
'A period has been created.'
|
||||
)
|
||||
);
|
||||
@ -184,7 +173,7 @@ class AccompanyingPeriodController extends AbstractController
|
||||
'person_id' => $person->getId(),
|
||||
]);
|
||||
}
|
||||
$flashBag->add('error', $this->get('translator')
|
||||
$flashBag->add('error', $this->translator
|
||||
->trans('Error! Period not created!'));
|
||||
|
||||
foreach ($errors as $error) {
|
||||
@ -244,7 +233,7 @@ class AccompanyingPeriodController extends AbstractController
|
||||
// in case the person is already open
|
||||
if ($person->isOpen()) {
|
||||
$this->get('session')->getFlashBag()
|
||||
->add('error', $this->get('translator')
|
||||
->add('error', $this->translator
|
||||
->trans(
|
||||
'Error! Period %name% is not closed ; it can be open',
|
||||
['%name%' => $person->__toString()]
|
||||
@ -276,7 +265,7 @@ class AccompanyingPeriodController extends AbstractController
|
||||
|
||||
if (\count($errors) <= 0) {
|
||||
$this->get('session')->getFlashBag()
|
||||
->add('success', $this->get('translator')
|
||||
->add('success', $this->translator
|
||||
->trans(
|
||||
'An accompanying period has been opened.',
|
||||
['%name%' => $person->__toString()]
|
||||
@ -289,7 +278,7 @@ class AccompanyingPeriodController extends AbstractController
|
||||
]);
|
||||
}
|
||||
$this->get('session')->getFlashBag()
|
||||
->add('error', $this->get('translator')
|
||||
->add('error', $this->translator
|
||||
->trans('Period not opened'));
|
||||
|
||||
foreach ($errors as $error) {
|
||||
@ -300,7 +289,7 @@ class AccompanyingPeriodController extends AbstractController
|
||||
$this->get('session')->getFlashBag()
|
||||
->add(
|
||||
'error',
|
||||
$this->get('translator')
|
||||
$this->translator
|
||||
->trans('Period not opened : form is invalid')
|
||||
);
|
||||
}
|
||||
@ -340,7 +329,7 @@ class AccompanyingPeriodController extends AbstractController
|
||||
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
|
||||
$this->addFlash('success', $this->get('translator')->trans(
|
||||
$this->addFlash('success', $this->translator->trans(
|
||||
'The period has been re-opened'
|
||||
));
|
||||
|
||||
@ -413,7 +402,7 @@ class AccompanyingPeriodController extends AbstractController
|
||||
|
||||
$flashBag->add(
|
||||
'success',
|
||||
$this->get('translator')->trans('An accompanying period has been updated.')
|
||||
$this->translator->trans('An accompanying period has been updated.')
|
||||
);
|
||||
|
||||
return $this->redirectToRoute('chill_person_accompanying_period_list', [
|
||||
@ -421,7 +410,7 @@ class AccompanyingPeriodController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
$flashBag->add('error', $this->get('translator')
|
||||
$flashBag->add('error', $this->translator
|
||||
->trans('Error when updating the period'));
|
||||
|
||||
foreach ($errors as $error) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user