mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-22 23:53:50 +00:00
replace old method of getting translator with injection of translatorInterface
This commit is contained in:
@@ -32,12 +32,13 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
|
||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
class UserController extends CRUDController
|
||||
{
|
||||
final public const FORM_GROUP_CENTER_COMPOSED = 'composed_groupcenter';
|
||||
|
||||
public function __construct(private readonly LoggerInterface $logger, private readonly ValidatorInterface $validator, private readonly UserPasswordEncoderInterface $passwordEncoder, private readonly UserRepository $userRepository, protected ParameterBagInterface $parameterBag) {}
|
||||
public function __construct(private readonly LoggerInterface $logger, private readonly ValidatorInterface $validator, private readonly UserPasswordEncoderInterface $passwordEncoder, private readonly UserRepository $userRepository, protected ParameterBagInterface $parameterBag, private readonly TranslatorInterface $translator) {}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/admin/main/user/{uid}/add_link_groupcenter",
|
||||
@@ -65,7 +66,7 @@ class UserController extends CRUDController
|
||||
if (0 === $this->validator->validate($user)->count()) {
|
||||
$em->flush();
|
||||
|
||||
$this->addFlash('success', $this->get('translator')->trans('The '
|
||||
$this->addFlash('success', $this->translator->trans('The '
|
||||
.'permissions have been successfully added to the user'));
|
||||
|
||||
$returnPathParams = $request->query->has('returnPath') ?
|
||||
@@ -115,14 +116,14 @@ class UserController extends CRUDController
|
||||
try {
|
||||
$user->removeGroupCenter($groupCenter);
|
||||
} catch (\RuntimeException $ex) {
|
||||
$this->addFlash('error', $this->get('translator')->trans($ex->getMessage()));
|
||||
$this->addFlash('error', $this->translator->trans($ex->getMessage()));
|
||||
|
||||
return $this->redirectToRoute('chill_crud_admin_user_edit', ['id' => $uid]);
|
||||
}
|
||||
|
||||
$em->flush();
|
||||
|
||||
$this->addFlash('success', $this->get('translator')
|
||||
$this->addFlash('success', $this->translator
|
||||
->trans('The permissions where removed.'));
|
||||
|
||||
return $this->redirectToRoute('chill_crud_admin_user_edit', ['id' => $uid]);
|
||||
@@ -207,7 +208,7 @@ class UserController extends CRUDController
|
||||
$user->setCurrentLocation($currentLocation);
|
||||
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
$this->addFlash('success', $this->get('translator')->trans('Current location successfully updated'));
|
||||
$this->addFlash('success', $this->translator->trans('Current location successfully updated'));
|
||||
|
||||
return $this->redirect(
|
||||
$request->query->has('returnPath') ? $request->query->get('returnPath') :
|
||||
@@ -243,7 +244,7 @@ class UserController extends CRUDController
|
||||
$user->setPassword($this->passwordEncoder->encodePassword($user, $password));
|
||||
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
$this->addFlash('success', $this->get('translator')->trans('Password successfully updated!'));
|
||||
$this->addFlash('success', $this->translator->trans('Password successfully updated!'));
|
||||
|
||||
return $this->redirect(
|
||||
$request->query->has('returnPath') ? $request->query->get('returnPath') :
|
||||
|
Reference in New Issue
Block a user