Fab 3 лет назад
Родитель
Сommit
8c68c0df0f
4 измененных файлов: 22 добавлений и 10 удалений
  1. +5
    -0
      Controller/Admin/UserController.php
  2. +5
    -5
      Form/Type/User/ChangePasswordFormType.php
  3. +11
    -4
      Resources/translations/admin.fr.yaml
  4. +1
    -1
      Translation/TranslatorAdmin.php

+ 5
- 0
Controller/Admin/UserController.php Просмотреть файл

@@ -12,6 +12,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use Symfony\Component\Translation\TranslatableMessage;

class UserController extends AbstractController
{
@@ -34,6 +35,8 @@ class UserController extends AbstractController

$this->em->update($user);
$this->em->flush();

$this->addFlash('success', new TranslatableMessage('form.account_profile.message.success', [], 'admin'));
}

return $this->render(
@@ -62,6 +65,8 @@ class UserController extends AbstractController

$this->em->update($user);
$this->em->flush();

$this->addFlash('success', new TranslatableMessage('form.account_password.message.success', [], 'admin'));
}

return $this->render(

+ 5
- 5
Form/Type/User/ChangePasswordFormType.php Просмотреть файл

@@ -53,7 +53,7 @@ class ChangePasswordFormType extends AbstractType
'current_password',
PasswordType::class,
[
'label' => 'form.change_password.current_password',
'label' => 'form.account_password.field.current_password',
'mapped' => false,
'constraints' => [
new NotBlank(),
@@ -63,14 +63,14 @@ class ChangePasswordFormType extends AbstractType
);

$builder->add(
'plainPassword',
'plain_password',
RepeatedType::class,
[
'type' => PasswordType::class,
'mapped' => false,
'first_options' => ['label' => 'form.change_password.new_password'],
'second_options' => ['label' => 'form.change_password.new_password_repeat'],
'invalid_message' => 'Les deux mots de passe ne correspondent pas.',
'first_options' => ['label' => 'form.account_password.field.new_password'],
'second_options' => ['label' => 'form.account_password.field.new_password_repeat'],
'invalid_message' => $this->translatorAdmin->trans('form.account_password.message.invalid_passwords'),
]
);


+ 11
- 4
Resources/translations/admin.fr.yaml Просмотреть файл

@@ -73,7 +73,14 @@ entity:
seo: Référencement

form:
change_password:
current_password: Mot de passe actuel
new_password: Nouveau mot de passe
new_password_repeat: Nouveau mot de passe (confirmer)
account_profile:
message:
success: Votre profil a bien été modifié
account_password:
field:
current_password: Mot de passe actuel
new_password: Nouveau mot de passe
new_password_repeat: Nouveau mot de passe (confirmer)
message:
success: Votre mot de passe a bien été modifié
invalid_passwords: Les deux mots de passe ne correspondent pas.

+ 1
- 1
Translation/TranslatorAdmin.php Просмотреть файл

@@ -122,7 +122,7 @@ class TranslatorAdmin
return 'entity.' . $entityName . '.' . $entitySection . '.' . $name;
}

private function trans($id, $params = [], $domain = self::DOMAIN): string
public function trans($id, $params = [], $domain = self::DOMAIN): string
{
return $this->translator->trans($id, $params, $domain);
}

Загрузка…
Отмена
Сохранить