fix(user): Appel à la route de modification d'un utilisateur dans l'API. (PATCH /ldap/user/update/{email})

- Adaptation de l'objet kazUser pour qu'il corresponde a l'attente de l'api.
This commit is contained in:
MLeveque
2026-04-05 14:07:50 +02:00
parent 7400d0d418
commit 6f9523f9e7
3 changed files with 64 additions and 27 deletions

View File

@@ -74,6 +74,12 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
#[ORM\Column(length: 20, nullable: true, name: 'telephone')]
private ?string $telephone = null;
private ?string $numeroMembre = null;
private ?bool $mailEnabled = null;
private ?string $mailAlias = null;
public function __construct() {
$this->emailQuota = self::EMAIL_QUOTA_DEFAULT;
}
@@ -312,6 +318,42 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
return $this;
}
public function getNumeroMembre(): ?string
{
return $this->numeroMembre;
}
public function setNumeroMembre(?string $numeroMembre): static
{
$this->numeroMembre = $numeroMembre;
return $this;
}
public function isMailEnabled(): ?bool
{
return $this->mailEnabled;
}
public function setMailEnabled(?bool $mailEnabled): static
{
$this->mailEnabled = $mailEnabled;
return $this;
}
public function getMailAlias(): ?string
{
return $this->mailAlias;
}
public function setMailAlias(?string $mailAlias): static
{
$this->mailAlias = $mailAlias;
return $this;
}
// Fonction qui permet d'afficher les données de l'API sur la page de profil
public function updateFromKazUser($kazUser) : User
{
@@ -332,31 +374,24 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
$this->setNextcloudQuota($kazUser['nextcloudQuota']);
$this->setQuota($kazUser['quota']);
$this->setIdentifiantKaz($kazUser['identifiantKaz']);
$this->setTelephone($kazUser['telephone'] ?? null);
return $this;
}
// Fonction qui permet de convertir les données de l'API vers $kazUser
public function convertToKazUser() : array
{
$fullName = implode(' ', array_filter([
$this->getFirstName(),
$this->getLastName()
]));
return [
'mail' => $this->getEmail(),
'sn' => $fullName,
$data = [
'numeroMembre' => $this->getNumeroMembre(),
'mailDeSecours' => $this->getAlternateEmail(),
'mailQuota' => $this->getEmailQuota(),
'agoraEnabled' => $this->hasAgoraAccess(),
'mobilizonEnabled' => $this->hasMobilizon(),
'mailEnabled' => $this->isMailEnabled(),
'nextcloudEnabled' => $this->hasNextcloudAccess(),
'nextcloudQuota' => $this->getNextcloudQuota(),
'quota' => $this->getQuota(),
'mobilizonEnabled' => $this->hasMobilizon(),
'agoraEnabled' => $this->hasAgoraAccess(),
'identifiantKaz' => $this->getIdentifiantKaz(),
'telephone' => $this->getTelephone(),
'mailAlias' => $this->getMailAlias(),
'quota' => $this->getQuota(),
];
return array_filter($data, fn($value) => $value !== null);
}
}