mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-11-23 12:27:44 +00:00
Ajouter une variable de localisation aux utilisateurs
This commit is contained in:
@@ -15,6 +15,7 @@ use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Notification\NotificationFlagManager;
|
||||
use Chill\MainBundle\Validation\Constraint\PhonenumberConstraint;
|
||||
use libphonenumber\PhoneNumber;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
final class UpdateProfileCommand
|
||||
{
|
||||
@@ -23,11 +24,13 @@ final class UpdateProfileCommand
|
||||
public function __construct(
|
||||
#[PhonenumberConstraint]
|
||||
public ?PhoneNumber $phonenumber,
|
||||
#[Assert\Choice(choices: ['fr', 'nl'], message: 'Locale must be either "fr" or "nl"')]
|
||||
public string $locale = 'fr',
|
||||
) {}
|
||||
|
||||
public static function create(User $user, NotificationFlagManager $flagManager): self
|
||||
{
|
||||
$updateProfileCommand = new self($user->getPhonenumber());
|
||||
$updateProfileCommand = new self($user->getPhonenumber(), $user->getLocale());
|
||||
|
||||
foreach ($flagManager->getAllNotificationFlagProviders() as $provider) {
|
||||
$updateProfileCommand->setNotificationFlag(
|
||||
|
||||
@@ -18,6 +18,7 @@ final readonly class UpdateProfileCommandHandler
|
||||
public function updateProfile(User $user, UpdateProfileCommand $command): void
|
||||
{
|
||||
$user->setPhonenumber($command->phonenumber);
|
||||
$user->setLocale($command->locale);
|
||||
|
||||
foreach ($command->notificationFlags as $flag => $values) {
|
||||
$user->setNotificationImmediately($flag, $values['immediate_email']);
|
||||
|
||||
Reference in New Issue
Block a user